From: YueHaibing <yuehaibing@huawei.com>
To: <jeyu@kernel.org>, <mbenes@suse.cz>, <yuehaibing@huawei.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH] kernel/module: Fix memleak in module_add_modinfo_attrs()
Date: Sat, 28 Dec 2019 19:54:55 +0800 [thread overview]
Message-ID: <20191228115455.24088-1-yuehaibing@huawei.com> (raw)
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")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
kernel/module.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/module.c b/kernel/module.c
index c3770b2..8ec670e 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -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;
}
--
2.7.4
next reply other threads:[~2019-12-28 11:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-28 11:54 YueHaibing [this message]
2020-01-08 8:05 ` [PATCH] kernel/module: Fix memleak in module_add_modinfo_attrs() Miroslav Benes
2020-01-08 16:24 ` Jessica Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191228115455.24088-1-yuehaibing@huawei.com \
--to=yuehaibing@huawei.com \
--cc=jeyu@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbenes@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox