All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-trivial] [PATCH v2] ossaudio: fix memory leak
@ 2015-06-24  9:18 ` arei.gonglei
  0 siblings, 0 replies; 6+ messages in thread
From: arei.gonglei @ 2015-06-24  9:18 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Gonglei, kraxel, armbru

From: Gonglei <arei.gonglei@huawei.com>

Variable "conf" going out of scope leaks the storage
it points to in line 856.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
v2:
 using an better way to avoid memory leak. (Markus) 
---
 audio/ossaudio.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index 11e76a1..94b473b 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -848,14 +848,11 @@ static OSSConf glob_conf = {
 
 static void *oss_audio_init (void)
 {
-    OSSConf *conf = g_malloc(sizeof(OSSConf));
-    *conf = glob_conf;
-
-    if (access(conf->devpath_in, R_OK | W_OK) < 0 ||
-        access(conf->devpath_out, R_OK | W_OK) < 0) {
+    if (access(glob_conf.devpath_in, R_OK | W_OK) < 0 ||
+        access(glob_conf.devpath_out, R_OK | W_OK) < 0) {
         return NULL;
     }
-    return conf;
+    return g_memdup(&glob_conf, sizeof(glob_conf));
 }
 
 static void oss_audio_fini (void *opaque)
-- 
1.7.12.4




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

* [Qemu-devel] [PATCH v2] ossaudio: fix memory leak
@ 2015-06-24  9:18 ` arei.gonglei
  0 siblings, 0 replies; 6+ messages in thread
From: arei.gonglei @ 2015-06-24  9:18 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Gonglei, kraxel, armbru

From: Gonglei <arei.gonglei@huawei.com>

Variable "conf" going out of scope leaks the storage
it points to in line 856.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
v2:
 using an better way to avoid memory leak. (Markus) 
---
 audio/ossaudio.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index 11e76a1..94b473b 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -848,14 +848,11 @@ static OSSConf glob_conf = {
 
 static void *oss_audio_init (void)
 {
-    OSSConf *conf = g_malloc(sizeof(OSSConf));
-    *conf = glob_conf;
-
-    if (access(conf->devpath_in, R_OK | W_OK) < 0 ||
-        access(conf->devpath_out, R_OK | W_OK) < 0) {
+    if (access(glob_conf.devpath_in, R_OK | W_OK) < 0 ||
+        access(glob_conf.devpath_out, R_OK | W_OK) < 0) {
         return NULL;
     }
-    return conf;
+    return g_memdup(&glob_conf, sizeof(glob_conf));
 }
 
 static void oss_audio_fini (void *opaque)
-- 
1.7.12.4

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

* Re: [Qemu-trivial] [PATCH v2] ossaudio: fix memory leak
  2015-06-24  9:18 ` [Qemu-devel] " arei.gonglei
@ 2015-06-25  6:49   ` Gerd Hoffmann
  -1 siblings, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2015-06-25  6:49 UTC (permalink / raw)
  To: arei.gonglei; +Cc: qemu-trivial, qemu-devel, armbru

On Mi, 2015-06-24 at 17:18 +0800, arei.gonglei@huawei.com wrote:
> Variable "conf" going out of scope leaks the storage
> it points to in line 856.
> 
Added to audio queue.

thanks,
  Gerd




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

* Re: [Qemu-devel] [PATCH v2] ossaudio: fix memory leak
@ 2015-06-25  6:49   ` Gerd Hoffmann
  0 siblings, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2015-06-25  6:49 UTC (permalink / raw)
  To: arei.gonglei; +Cc: qemu-trivial, qemu-devel, armbru

On Mi, 2015-06-24 at 17:18 +0800, arei.gonglei@huawei.com wrote:
> Variable "conf" going out of scope leaks the storage
> it points to in line 856.
> 
Added to audio queue.

thanks,
  Gerd

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

* Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] ossaudio: fix memory leak
  2015-06-24  9:18 ` [Qemu-devel] " arei.gonglei
@ 2015-06-25  6:55   ` Markus Armbruster
  -1 siblings, 0 replies; 6+ messages in thread
From: Markus Armbruster @ 2015-06-25  6:55 UTC (permalink / raw)
  To: arei.gonglei; +Cc: qemu-trivial, qemu-devel, kraxel

<arei.gonglei@huawei.com> writes:

> From: Gonglei <arei.gonglei@huawei.com>
>
> Variable "conf" going out of scope leaks the storage
> it points to in line 856.
>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
> v2:
>  using an better way to avoid memory leak. (Markus) 
> ---
>  audio/ossaudio.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/audio/ossaudio.c b/audio/ossaudio.c
> index 11e76a1..94b473b 100644
> --- a/audio/ossaudio.c
> +++ b/audio/ossaudio.c
> @@ -848,14 +848,11 @@ static OSSConf glob_conf = {
>  
>  static void *oss_audio_init (void)
>  {
> -    OSSConf *conf = g_malloc(sizeof(OSSConf));
> -    *conf = glob_conf;
> -
> -    if (access(conf->devpath_in, R_OK | W_OK) < 0 ||
> -        access(conf->devpath_out, R_OK | W_OK) < 0) {
> +    if (access(glob_conf.devpath_in, R_OK | W_OK) < 0 ||
> +        access(glob_conf.devpath_out, R_OK | W_OK) < 0) {
>          return NULL;
>      }
> -    return conf;
> +    return g_memdup(&glob_conf, sizeof(glob_conf));
>  }
>  
>  static void oss_audio_fini (void *opaque)

Reviewed-by: Markus Armbruster <armbru@redhat.com>

Now I get to add g_memdup() to scripts/coverity-model.c...


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

* Re: [Qemu-devel] [PATCH v2] ossaudio: fix memory leak
@ 2015-06-25  6:55   ` Markus Armbruster
  0 siblings, 0 replies; 6+ messages in thread
From: Markus Armbruster @ 2015-06-25  6:55 UTC (permalink / raw)
  To: arei.gonglei; +Cc: qemu-trivial, qemu-devel, kraxel

<arei.gonglei@huawei.com> writes:

> From: Gonglei <arei.gonglei@huawei.com>
>
> Variable "conf" going out of scope leaks the storage
> it points to in line 856.
>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
> v2:
>  using an better way to avoid memory leak. (Markus) 
> ---
>  audio/ossaudio.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/audio/ossaudio.c b/audio/ossaudio.c
> index 11e76a1..94b473b 100644
> --- a/audio/ossaudio.c
> +++ b/audio/ossaudio.c
> @@ -848,14 +848,11 @@ static OSSConf glob_conf = {
>  
>  static void *oss_audio_init (void)
>  {
> -    OSSConf *conf = g_malloc(sizeof(OSSConf));
> -    *conf = glob_conf;
> -
> -    if (access(conf->devpath_in, R_OK | W_OK) < 0 ||
> -        access(conf->devpath_out, R_OK | W_OK) < 0) {
> +    if (access(glob_conf.devpath_in, R_OK | W_OK) < 0 ||
> +        access(glob_conf.devpath_out, R_OK | W_OK) < 0) {
>          return NULL;
>      }
> -    return conf;
> +    return g_memdup(&glob_conf, sizeof(glob_conf));
>  }
>  
>  static void oss_audio_fini (void *opaque)

Reviewed-by: Markus Armbruster <armbru@redhat.com>

Now I get to add g_memdup() to scripts/coverity-model.c...

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

end of thread, other threads:[~2015-06-25  6:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-24  9:18 [Qemu-trivial] [PATCH v2] ossaudio: fix memory leak arei.gonglei
2015-06-24  9:18 ` [Qemu-devel] " arei.gonglei
2015-06-25  6:49 ` [Qemu-trivial] " Gerd Hoffmann
2015-06-25  6:49   ` [Qemu-devel] " Gerd Hoffmann
2015-06-25  6:55 ` [Qemu-trivial] " Markus Armbruster
2015-06-25  6:55   ` Markus Armbruster

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.