Patchwork [5/6] qemu-ga: Plug fd leak on ga_channel_open() error paths

login
register
mail settings
Submitter Markus Armbruster
Date Jan. 11, 2013, 10:25 a.m.
Message ID <1357899902-5316-6-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/211290/
State New
Headers show

Comments

Markus Armbruster - Jan. 11, 2013, 10:25 a.m.
Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qga/channel-posix.c | 1 +
 1 file changed, 1 insertion(+)
Michael Roth - Jan. 11, 2013, 5:44 p.m.
On Fri, Jan 11, 2013 at 11:25:01AM +0100, Markus Armbruster wrote:
> Spotted by Coverity.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>

> ---
>  qga/channel-posix.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/qga/channel-posix.c b/qga/channel-posix.c
> index 5579185..b530808 100644
> --- a/qga/channel-posix.c
> +++ b/qga/channel-posix.c
> @@ -153,6 +153,7 @@ static gboolean ga_channel_open(GAChannel *c, const gchar *path, GAChannelMethod
>          ret = ga_channel_client_add(c, fd);
>          if (ret) {
>              g_critical("error adding channel to main loop");
> +            close(fd);
>              return false;
>          }
>          break;
> -- 
> 1.7.11.7
>

Patch

diff --git a/qga/channel-posix.c b/qga/channel-posix.c
index 5579185..b530808 100644
--- a/qga/channel-posix.c
+++ b/qga/channel-posix.c
@@ -153,6 +153,7 @@  static gboolean ga_channel_open(GAChannel *c, const gchar *path, GAChannelMethod
         ret = ga_channel_client_add(c, fd);
         if (ret) {
             g_critical("error adding channel to main loop");
+            close(fd);
             return false;
         }
         break;