All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hw/audio: fix a memory leak in OPLCreate()
@ 2019-10-23  9:53 Jidong Xia
  2019-10-24  8:14 ` Gerd Hoffmann
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jidong Xia @ 2019-10-23  9:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jidong Xia, kraxel

There is a memory leak in OPLCreate(),Should free allocated mem
before return.

Signed-off-by: Jidong Xia <xiajidong@cmss.chinamobile.com>
---
 hw/audio/fmopl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/audio/fmopl.c b/hw/audio/fmopl.c
index 9f50a89..ca9825b 100644
--- a/hw/audio/fmopl.c
+++ b/hw/audio/fmopl.c
@@ -1112,6 +1112,7 @@ FM_OPL *OPLCreate(int clock, int rate)
 		opl_dbg_maxchip++;
 	}
 #endif
+	free(ptr);
 	return OPL;
 }
 
-- 
1.8.3.1





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] hw/audio: fix a memory leak in OPLCreate()
  2019-10-23  9:53 [PATCH] hw/audio: fix a memory leak in OPLCreate() Jidong Xia
@ 2019-10-24  8:14 ` Gerd Hoffmann
  2019-10-24  8:25 ` Stefano Garzarella
  2019-10-24 11:31 ` no-reply
  2 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2019-10-24  8:14 UTC (permalink / raw)
  To: Jidong Xia; +Cc: qemu-devel

On Wed, Oct 23, 2019 at 05:53:40PM +0800, Jidong Xia wrote:
> There is a memory leak in OPLCreate(),

No, it's released properly in OPLDestroy().

cheers,
  Gerd



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hw/audio: fix a memory leak in OPLCreate()
  2019-10-23  9:53 [PATCH] hw/audio: fix a memory leak in OPLCreate() Jidong Xia
  2019-10-24  8:14 ` Gerd Hoffmann
@ 2019-10-24  8:25 ` Stefano Garzarella
  2019-10-24  9:36   ` xiajidong
  2019-10-24 11:31 ` no-reply
  2 siblings, 1 reply; 5+ messages in thread
From: Stefano Garzarella @ 2019-10-24  8:25 UTC (permalink / raw)
  To: Jidong Xia; +Cc: qemu-devel, kraxel

On Wed, Oct 23, 2019 at 05:53:40PM +0800, Jidong Xia wrote:
> There is a memory leak in OPLCreate(),Should free allocated mem
> before return.
> 
> Signed-off-by: Jidong Xia <xiajidong@cmss.chinamobile.com>
> ---
>  hw/audio/fmopl.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/audio/fmopl.c b/hw/audio/fmopl.c
> index 9f50a89..ca9825b 100644
> --- a/hw/audio/fmopl.c
> +++ b/hw/audio/fmopl.c
> @@ -1112,6 +1112,7 @@ FM_OPL *OPLCreate(int clock, int rate)
>  		opl_dbg_maxchip++;
>  	}
>  #endif
> +	free(ptr);
>  	return OPL;

I don't know this code well, but I don't think is correct to free 'ptr' in
the success case, since it is the pointer returned by this function that
will be freed by OPLDestroy().

Does that sound right or did I miss something?

Thanks,
Stefano


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hw/audio: fix a memory leak in OPLCreate()
  2019-10-24  8:25 ` Stefano Garzarella
@ 2019-10-24  9:36   ` xiajidong
  0 siblings, 0 replies; 5+ messages in thread
From: xiajidong @ 2019-10-24  9:36 UTC (permalink / raw)
  To: Stefano Garzarella; +Cc: qemu-devel, kraxel



On 10/24/19 4:25 AM, Stefano Garzarella wrote:
> On Wed, Oct 23, 2019 at 05:53:40PM +0800, Jidong Xia wrote:
>> There is a memory leak in OPLCreate(),Should free allocated mem
>> before return.
>>
>> Signed-off-by: Jidong Xia <xiajidong@cmss.chinamobile.com>
>> ---
>>   hw/audio/fmopl.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/hw/audio/fmopl.c b/hw/audio/fmopl.c
>> index 9f50a89..ca9825b 100644
>> --- a/hw/audio/fmopl.c
>> +++ b/hw/audio/fmopl.c
>> @@ -1112,6 +1112,7 @@ FM_OPL *OPLCreate(int clock, int rate)
>>   		opl_dbg_maxchip++;
>>   	}
>>   #endif
>> +	free(ptr);
>>   	return OPL;
> 
> I don't know this code well, but I don't think is correct to free 'ptr' in
> the success case, since it is the pointer returned by this function that
> will be freed by OPLDestroy().
> 
> Does that sound right or did I miss something?
ok, I understand it.
> 
> Thanks,
> Stefano
> 
> 
Thanks,
Jidong Xia




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hw/audio: fix a memory leak in OPLCreate()
  2019-10-23  9:53 [PATCH] hw/audio: fix a memory leak in OPLCreate() Jidong Xia
  2019-10-24  8:14 ` Gerd Hoffmann
  2019-10-24  8:25 ` Stefano Garzarella
@ 2019-10-24 11:31 ` no-reply
  2 siblings, 0 replies; 5+ messages in thread
From: no-reply @ 2019-10-24 11:31 UTC (permalink / raw)
  To: xiajidong; +Cc: xiajidong, qemu-devel, kraxel

Patchew URL: https://patchew.org/QEMU/1571824420-24893-1-git-send-email-xiajidong@cmss.chinamobile.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [PATCH] hw/audio: fix a memory leak in OPLCreate()
Type: series
Message-id: 1571824420-24893-1-git-send-email-xiajidong@cmss.chinamobile.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 - [tag update]      patchew/20191023101956.19120-1-kraxel@redhat.com -> patchew/20191023101956.19120-1-kraxel@redhat.com
 * [new tag]         patchew/20191024074307.22821-1-ganeshgr@linux.ibm.com -> patchew/20191024074307.22821-1-ganeshgr@linux.ibm.com
Switched to a new branch 'test'
8f01555 hw/audio: fix a memory leak in OPLCreate()

=== OUTPUT BEGIN ===
ERROR: code indent should never use tabs
#21: FILE: hw/audio/fmopl.c:1115:
+^Ifree(ptr);$

total: 1 errors, 0 warnings, 7 lines checked

Commit 8f01555c7bba (hw/audio: fix a memory leak in OPLCreate()) has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/1571824420-24893-1-git-send-email-xiajidong@cmss.chinamobile.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-10-24 12:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-23  9:53 [PATCH] hw/audio: fix a memory leak in OPLCreate() Jidong Xia
2019-10-24  8:14 ` Gerd Hoffmann
2019-10-24  8:25 ` Stefano Garzarella
2019-10-24  9:36   ` xiajidong
2019-10-24 11:31 ` no-reply

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.