[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200221072407.509394798@linuxfoundation.org>
Date: Fri, 21 Feb 2020 08:36:18 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, Miroslav Benes <mbenes@...e.cz>,
YueHaibing <yuehaibing@...wei.com>, Jessica Yu <jeyu@...nel.org>,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH 5.5 053/399] kernel/module: Fix memleak in module_add_modinfo_attrs()
From: YueHaibing <yuehaibing@...wei.com>
[ 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@...e.cz>
Signed-off-by: YueHaibing <yuehaibing@...wei.com>
Signed-off-by: Jessica Yu <jeyu@...nel.org>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
kernel/module.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/module.c b/kernel/module.c
index b56f3224b161b..8785e31c2dd0f 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1781,6 +1781,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;
}
--
2.20.1
Powered by blists - more mailing lists