Patchwork [12/14] linux-user: Remove redundant null check and replace free by g_free

login
register
mail settings
Submitter Stefan Hajnoczi
Date Sept. 23, 2012, 10 a.m.
Message ID <1348394420-28298-13-git-send-email-stefanha@gmail.com>
Download mbox | patch
Permalink /patch/186199/
State New
Headers show

Comments

Stefan Hajnoczi - Sept. 23, 2012, 10 a.m.
From: Stefan Weil <sw@weilnetz.de>

Report from smatch:

linux-user/syscall.c:3632 do_ioctl_dm(220) info:
 redundant null check on big_buf calling free()

'big_buf' was allocated by g_malloc0, therefore free was also
replaced by g_free.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
---
 linux-user/syscall.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 6257a04..471d060 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3628,9 +3628,7 @@  static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
         unlock_user(argptr, arg, target_size);
     }
 out:
-    if (big_buf) {
-        free(big_buf);
-    }
+    g_free(big_buf);
     return ret;
 }