linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: xinhui <xinhui@linux.vnet.ibm.com>
To: Nathan Fontenot <nfont@linux.vnet.ibm.com>,
	xinhui <xinhui.pan@linux.vnet.ibm.com>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Cc: Andrzej Hajda <a.hajda@samsung.com>,
	Christophe Jaillet <christophe.jaillet@wanadoo.fr>,
	Hari Bathini <hbathini@linux.vnet.ibm.com>,
	Paul Mackerras <paulus@samba.org>
Subject: Re: [PATCH] powerpc/nvram: Fix a memory leak in err path
Date: Thu, 10 Dec 2015 07:52:05 +0800	[thread overview]
Message-ID: <5668BEA5.1000002@linux.vnet.ibm.com> (raw)
In-Reply-To: <566846F5.2020507@linux.vnet.ibm.com>


On 2015/12/9 23:21, Nathan Fontenot wrote:
> On 12/09/2015 04:00 AM, xinhui wrote:
>>
>> If kmemdup fails, We need kfree *buff* first then return -ENOMEM.
>> Otherwise there is a memory leak.
>>
>> Signed-off-by: Pan Xinhui <xinhui.pan@linux.vnet.ibm.com>
>
> Reviewed-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
>

Hi Nathan,
	thank you for doing that :)

thanks
xinhui

>> ---
>>   arch/powerpc/kernel/nvram_64.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
>> index 32e2652..21a278b7 100644
>> --- a/arch/powerpc/kernel/nvram_64.c
>> +++ b/arch/powerpc/kernel/nvram_64.c
>> @@ -542,9 +542,9 @@ static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type,
>>   			time->tv_nsec = 0;
>>   		}
>>   		*buf = kmemdup(buff + hdr_size, length, GFP_KERNEL);
>> +		kfree(buff);
>>   		if (*buf == NULL)
>>   			return -ENOMEM;
>> -		kfree(buff);
>>
>>   		if (err_type == ERR_TYPE_KERNEL_PANIC_GZ)
>>   			*compressed = true;
>>

  reply	other threads:[~2015-12-09 23:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-09 10:00 [PATCH] powerpc/nvram: Fix a memory leak in err path xinhui
2015-12-09 15:21 ` Nathan Fontenot
2015-12-09 23:52   ` xinhui [this message]
2016-09-20 13:07 ` Michael Ellerman

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=5668BEA5.1000002@linux.vnet.ibm.com \
    --to=xinhui@linux.vnet.ibm.com \
    --cc=a.hajda@samsung.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=hbathini@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=nfont@linux.vnet.ibm.com \
    --cc=paulus@samba.org \
    --cc=xinhui.pan@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).