Commit bdfaaf35 authored by YueHaibing's avatar YueHaibing Committed by Greg Kroah-Hartman

kernel/module: Fix memleak in module_add_modinfo_attrs()

[ Upstream commit f6d061d6 ]

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: bc6f2a75 ("kernel/module: Fix mem leak in module_add_modinfo_attrs")
Reviewed-by: default avatarMiroslav Benes <mbenes@suse.cz>
Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
Signed-off-by: default avatarJessica Yu <jeyu@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 4f98fe43
...@@ -1729,6 +1729,8 @@ static int module_add_modinfo_attrs(struct module *mod) ...@@ -1729,6 +1729,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;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment