Commit f6d061d6 authored by YueHaibing's avatar YueHaibing Committed by Jessica Yu

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: 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>
parent ce2b617c
......@@ -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;
}
......
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