kernel/module: Fix memleak in module_add_modinfo_attrs()
PATCH 1/1 kernel/module: Fix memleak in module_add_modinfo_attrs()
In module_add_modinfo_attrs() if sysfs_create_file() fails on the first iteration of the loop (so i = 0), we forget to free the modinfo_attrs.
Fixes bc6f2a757d52 ("kernel/module: Fix mem leak in module_add_modinfo_attrs")
Signed-off-by YueHaibing <[email protected]>
--- kernel/module.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/module.c +2 -0
@@ -1784,6 +1784,8 @@ static int module_add_modinfo_attrs(struct module *mod) error_out:if (i >0 )module_remove_modinfo_attrs (mod, --i); +else +kfree (mod->modinfo_attrs);return error; }
Signature · 1 line
2.7.4
Quoted 6 lines · YueHaibing
In
module_add_modinfo_attrs()ifsysfs_create_file()fails on the first iteration of the loop (so i = 0), we forget to free themodinfo_attrs.Fixes bc6f2a757d52 ("kernel/module: Fix mem leak in module_add_modinfo_attrs")Signed-off-by YueHaibing <[email protected]>
Reviewed-by Miroslav Benes <[email protected]>
M
Jessica Yu
Applied+++ YueHaibing [28/12/19 19:54 +0800]:
Quoted 6 lines
In
module_add_modinfo_attrs()ifsysfs_create_file()fails on the first iteration of the loop (so i = 0), we forget to free themodinfo_attrs.Fixes bc6f2a757d52 ("kernel/module: Fix mem leak in module_add_modinfo_attrs")Signed-off-by YueHaibing <[email protected]>
Applied, thanks!
Jessica
Quoted 21 lines
---
kernel/module.c| 2 ++1 file changed, 2 insertions(+)kernel/module.c +0
-0@@ -1784,6 +1784,8 @@ static int module_add_modinfo_attrs(struct module *mod)
error_out:if (i > 0) module_remove_modinfo_attrs(mod, --i);kernel/module.c +2
-0+else +kfree (mod->modinfo_attrs);return error; }Signature · 1 line
2.7.4