diff mbox series

[RESEND,v2,2/7] qga/channel-posix: Plug memory leak in ga_channel_write_all()

Message ID 20201023061218.2080844-3-kuhn.chenqun@huawei.com (mailing list archive)
State New, archived
Headers show
Series some memleak trivial patchs | expand

Commit Message

Chen Qun Oct. 23, 2020, 6:12 a.m. UTC
From: Pan Nengyuan <pannengyuan@huawei.com>

Missing g_error_free on error path in ga_channel_write_all(). Fix that.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
---
Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 qga/channel-posix.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Chen Qun Dec. 14, 2020, 2:04 a.m. UTC | #1
Kindly ping!

Hi Michael,
  It's a bug, though it's trivial. 
Could you review it and add your queues or add trivial queues?

Thanks,
Chen Qun

> -----Original Message-----
> From: Chenqun (kuhn)
> Sent: Friday, October 23, 2020 2:12 PM
> To: qemu-devel@nongnu.org; qemu-trivial@nongnu.org
> Cc: Pannengyuan <pannengyuan@huawei.com>; lvivier@redhat.com;
> Zhanghailiang <zhang.zhanghailiang@huawei.com>; ganqixin
> <ganqixin@huawei.com>; Euler Robot <euler.robot@huawei.com>; Li Qiang
> <liq3ea@gmail.com>; Chenqun (kuhn) <kuhn.chenqun@huawei.com>; Michael
> Roth <mdroth@linux.vnet.ibm.com>
> Subject: [PATCH RESEND v2 2/7] qga/channel-posix: Plug memory leak in
> ga_channel_write_all()
> 
> From: Pan Nengyuan <pannengyuan@huawei.com>
> 
> Missing g_error_free on error path in ga_channel_write_all(). Fix that.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> Reviewed-by: Li Qiang <liq3ea@gmail.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
> Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
> ---
>  qga/channel-posix.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/qga/channel-posix.c b/qga/channel-posix.c index
> 0373975360..8f3821af6d 100644
> --- a/qga/channel-posix.c
> +++ b/qga/channel-posix.c
> @@ -249,7 +249,7 @@ GIOStatus ga_channel_write_all(GAChannel *c, const
> gchar *buf, gsize size)
>              buf += written;
>          } else if (status != G_IO_STATUS_AGAIN) {
>              g_warning("error writing to channel: %s", err->message);
> -            return status;
> +            goto out;
>          }
>      }
> 
> @@ -261,6 +261,10 @@ GIOStatus ga_channel_write_all(GAChannel *c,
> const gchar *buf, gsize size)
>          g_warning("error flushing channel: %s", err->message);
>      }
> 
> +out:
> +    if (err) {
> +        g_error_free(err);
> +    }
>      return status;
>  }
> 
> --
> 2.23.0
diff mbox series

Patch

diff --git a/qga/channel-posix.c b/qga/channel-posix.c
index 0373975360..8f3821af6d 100644
--- a/qga/channel-posix.c
+++ b/qga/channel-posix.c
@@ -249,7 +249,7 @@  GIOStatus ga_channel_write_all(GAChannel *c, const gchar *buf, gsize size)
             buf += written;
         } else if (status != G_IO_STATUS_AGAIN) {
             g_warning("error writing to channel: %s", err->message);
-            return status;
+            goto out;
         }
     }
 
@@ -261,6 +261,10 @@  GIOStatus ga_channel_write_all(GAChannel *c, const gchar *buf, gsize size)
         g_warning("error flushing channel: %s", err->message);
     }
 
+out:
+    if (err) {
+        g_error_free(err);
+    }
     return status;
 }