kernel/module: Fix memleak in module_add_modinfo_attrs()
authorYueHaibing <yuehaibing@huawei.com>
Sat, 28 Dec 2019 11:54:55 +0000 (19:54 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Feb 2020 12:33:50 +0000 (04:33 -0800)
commitbdfaaf35ac49ef43d1f3a6ccf6f27b8e64f61828
tree7d56152953bfd07e5a7a07da55cc3563efa11d08
parent4f98fe43cdaaeced34c2e6f6d1b76ed0d712bd2a
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>
kernel/module.c