mirror of https://gitee.com/openkylin/linux.git
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: bc6f2a757d
("kernel/module: Fix mem leak in module_add_modinfo_attrs")
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
This commit is contained in:
parent
ce2b617ce8
commit
f6d061d617
|
@ -1784,6 +1784,8 @@ static int module_add_modinfo_attrs(struct module *mod)
|
||||||
error_out:
|
error_out:
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
module_remove_modinfo_attrs(mod, --i);
|
module_remove_modinfo_attrs(mod, --i);
|
||||||
|
else
|
||||||
|
kfree(mod->modinfo_attrs);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue