History

kernel/fail_function: fix memory leak with using debugfs_lookup()

When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. To make things simpler, just call debugfs_lookup_and_remove() instead which handles all of the logic at once.

Greg Kroah-Hartman committed 3 years ago

Commit 2bb36691 parent a0bc3f71 file · +1 −4Browse files

Showing the changes to kernel/fail_function.c (1 of 1 file). Show all

Unified · Split

kernel/fail_function.c+1−4
@@ -163,10 +163,7 @@ static void fei_debugfs_add_attr(struct fei_attr *attr) · 162 unmodified lines
163163
164164 static void fei_debugfs_remove_attr(struct fei_attr *attr)
165165 {
166− struct dentry *dir;
167−
168− dir = debugfs_lookup(attr->kp.symbol_name, fei_debugfs_dir);
169− debugfs_remove_recursive(dir);
166+ debugfs_lookup_and_remove(attr->kp.symbol_name, fei_debugfs_dir);
170167 }
171168
172169 static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs)