diff options
author | YueHaibing <yuehaibing@huawei.com> | 2019-12-28 19:54:55 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-02-11 04:33:50 -0800 |
commit | bdfaaf35ac49ef43d1f3a6ccf6f27b8e64f61828 (patch) | |
tree | 7d56152953bfd07e5a7a07da55cc3563efa11d08 /kernel/module.c | |
parent | 4f98fe43cdaaeced34c2e6f6d1b76ed0d712bd2a (diff) | |
download | linux-stable-bdfaaf35ac49ef43d1f3a6ccf6f27b8e64f61828.tar.gz linux-stable-bdfaaf35ac49ef43d1f3a6ccf6f27b8e64f61828.tar.bz2 linux-stable-bdfaaf35ac49ef43d1f3a6ccf6f27b8e64f61828.zip |
kernel/module: Fix memleak in module_add_modinfo_attrs()
[ Upstream commit f6d061d617124abbd55396a3bc37b9bf7d33233c ]
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")
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/module.c b/kernel/module.c index d3aaec62c142..70a75a7216ab 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1729,6 +1729,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; } |