diff mbox

[v3,4/4] ivshmem: Fix fd leak on error

Message ID 1410799208-3250-5-git-send-email-afaerber@suse.de
State New
Headers show

Commit Message

Andreas Färber Sept. 15, 2014, 4:40 p.m. UTC
Reported-by: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/misc/ivshmem.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Michael S. Tsirkin Sept. 22, 2014, 11:22 a.m. UTC | #1
On Mon, Sep 15, 2014 at 06:40:08PM +0200, Andreas Färber wrote:
> Reported-by: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Andreas Färber <afaerber@suse.de>

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  hw/misc/ivshmem.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
> index ecef82a..bf585b7 100644
> --- a/hw/misc/ivshmem.c
> +++ b/hw/misc/ivshmem.c
> @@ -512,6 +512,7 @@ static void ivshmem_read(void *opaque, const uint8_t *buf, int size)
>      if (incoming_fd == -1) {
>          fprintf(stderr, "could not allocate file descriptor %s\n",
>                                                              strerror(errno));
> +        close(tmp_fd);
>          return;
>      }
>  
> -- 
> 1.8.4.5
diff mbox

Patch

diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index ecef82a..bf585b7 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -512,6 +512,7 @@  static void ivshmem_read(void *opaque, const uint8_t *buf, int size)
     if (incoming_fd == -1) {
         fprintf(stderr, "could not allocate file descriptor %s\n",
                                                             strerror(errno));
+        close(tmp_fd);
         return;
     }