Patchwork [4/6] qemu-ga: Plug fd leak on ga_channel_listen_accept() error path

login
register
mail settings
Submitter Markus Armbruster
Date Jan. 11, 2013, 10:25 a.m.
Message ID <1357899902-5316-5-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/211291/
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:00AM +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 d4fd628..5579185 100644
> --- a/qga/channel-posix.c
> +++ b/qga/channel-posix.c
> @@ -45,6 +45,7 @@ static gboolean ga_channel_listen_accept(GIOChannel *channel,
>      ret = ga_channel_client_add(c, client_fd);
>      if (ret) {
>          g_warning("error setting up connection");
> +        close(client_fd);
>          goto out;
>      }
>      accepted = true;
> -- 
> 1.7.11.7
>

Patch

diff --git a/qga/channel-posix.c b/qga/channel-posix.c
index d4fd628..5579185 100644
--- a/qga/channel-posix.c
+++ b/qga/channel-posix.c
@@ -45,6 +45,7 @@  static gboolean ga_channel_listen_accept(GIOChannel *channel,
     ret = ga_channel_client_add(c, client_fd);
     if (ret) {
         g_warning("error setting up connection");
+        close(client_fd);
         goto out;
     }
     accepted = true;