From: Firo Yang <firogm@gmail.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] firmware: Fix memory leak in error path
Date: Sat, 06 Jun 2015 03:13:07 +0000 [thread overview]
Message-ID: <20150606031307.GA5895@firo> (raw)
In-Reply-To: <1433522316-23063-1-git-send-email-firogm@gmail.com>
On Fri, Jun 05, 2015 at 06:43:33PM +0200, Julia Lawall wrote:
>On Sat, 6 Jun 2015, Firo Yang wrote:
>
>> In error path, we forgot to free fw_work alloced by kzalloc.
>> This will make a memory leak. So just free it before return.
>>
>> Signed-off-by: Firo Yang <firogm@gmail.com>
>> ---
>> drivers/base/firmware_class.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
>> index 8c3aa3c..9c42883 100644
>> --- a/drivers/base/firmware_class.c
>> +++ b/drivers/base/firmware_class.c
>> @@ -1307,8 +1307,10 @@ request_firmware_nowait(
>>
>> fw_work->module = module;
>> fw_work->name = kstrdup_const(name, gfp);
>> - if (!fw_work->name)
>> + if (!fw_work->name) {
>> + kfree(fw_work);
>> return -ENOMEM;
>> + }
>
>Maybe it would be better to unify the error handling code at the end of
>the function, if things are being forgotten.
Thanks Julia!
I will reconstruct the code.
Firo
>
>julia
>
>> fw_work->device = device;
>> fw_work->context = context;
>> fw_work->cont = cont;
>> --
>> 2.4.2
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
--
prev parent reply other threads:[~2015-06-06 3:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-05 16:38 [PATCH] firmware: Fix memory leak in error path Firo Yang
2015-06-05 16:43 ` Julia Lawall
2015-06-06 3:13 ` Firo Yang [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=20150606031307.GA5895@firo \
--to=firogm@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
/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