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
163 163
164static void fei_debugfs_remove_attr(struct fei_attr *attr)164static void fei_debugfs_remove_attr(struct fei_attr *attr)
165{165{
166 struct dentry *dir;166 debugfs_lookup_and_remove(attr->kp.symbol_name, fei_debugfs_dir);
167
168 dir = debugfs_lookup(attr->kp.symbol_name, fei_debugfs_dir);
169 debugfs_remove_recursive(dir);
170}167}
171 168
172static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs)169static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs)