public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jessica Yu <jeyu@kernel.org>
To: YueHaibing <yuehaibing@huawei.com>
Cc: mbenes@suse.cz, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kernel/module: Fix memleak in module_add_modinfo_attrs()
Date: Wed, 8 Jan 2020 17:24:12 +0100	[thread overview]
Message-ID: <20200108162412.GA12869@linux-8ccs> (raw)
In-Reply-To: <20191228115455.24088-1-yuehaibing@huawei.com>

+++ YueHaibing [28/12/19 19:54 +0800]:
>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>

Applied, thanks!

Jessica

>---
> 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
>
>

      parent reply	other threads:[~2020-01-08 16:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-28 11:54 [PATCH] kernel/module: Fix memleak in module_add_modinfo_attrs() YueHaibing
2020-01-08  8:05 ` Miroslav Benes
2020-01-08 16:24 ` Jessica Yu [this message]

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=20200108162412.GA12869@linux-8ccs \
    --to=jeyu@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=yuehaibing@huawei.com \
    /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