diff mbox

RDMA: Missing free in (probably unreachable) error path

Message ID 1434986319-22294-1-git-send-email-dgilbert@redhat.com
State New
Headers show

Commit Message

Dr. David Alan Gilbert June 22, 2015, 3:18 p.m. UTC
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Coverity CID 1307773

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 migration/rdma.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Andreas Färber June 22, 2015, 4:51 p.m. UTC | #1
Am 22.06.2015 um 17:18 schrieb Dr. David Alan Gilbert (git):
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> Coverity CID 1307773
> 
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

Reviewed-by: Andreas Färber <afaerber@suse.de>

Regards,
Andreas
Juan Quintela July 1, 2015, 8:33 a.m. UTC | #2
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> Coverity CID 1307773
>
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

Integrated gonglei patch for this, just moved the malloc.

> ---
>  migration/rdma.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/migration/rdma.c b/migration/rdma.c
> index 53e611e..2a9e0ce 100644
> --- a/migration/rdma.c
> +++ b/migration/rdma.c
> @@ -3395,6 +3395,7 @@ static void *qemu_fopen_rdma(RDMAContext *rdma, const char *mode)
>      QEMUFileRDMA *r = g_malloc0(sizeof(QEMUFileRDMA));
>  
>      if (qemu_file_mode_is_not_valid(mode)) {
> +        g_free(r);
>          return NULL;
>      }
diff mbox

Patch

diff --git a/migration/rdma.c b/migration/rdma.c
index 53e611e..2a9e0ce 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -3395,6 +3395,7 @@  static void *qemu_fopen_rdma(RDMAContext *rdma, const char *mode)
     QEMUFileRDMA *r = g_malloc0(sizeof(QEMUFileRDMA));
 
     if (qemu_file_mode_is_not_valid(mode)) {
+        g_free(r);
         return NULL;
     }