]> Git Repo - qemu.git/commitdiff
nbd: fix memory leak in nbd_opt_go()
authorPhilippe Mathieu-Daudé <[email protected]>
Thu, 27 Jul 2017 02:42:09 +0000 (23:42 -0300)
committerEric Blake <[email protected]>
Fri, 28 Jul 2017 16:58:20 +0000 (11:58 -0500)
nbd/client.c:385:12: warning: Potential leak of memory pointed to by 'buf'

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Message-Id: <20170727024224[email protected]>
[introduced in commit 8ecaeae8]
Signed-off-by: Eric Blake <[email protected]>
nbd/client.c

index 509ed5e4ba8e1e869147a2bae7c469ab15a7e99f..0a17de80b51f619b3ef14bb524b26e9170a14fbe 100644 (file)
@@ -376,9 +376,11 @@ static int nbd_opt_go(QIOChannel *ioc, const char *wantname,
     if (info->request_sizes) {
         stw_be_p(buf + 4 + len + 2, NBD_INFO_BLOCK_SIZE);
     }
-    if (nbd_send_option_request(ioc, NBD_OPT_GO,
-                                4 + len + 2 + 2 * info->request_sizes, buf,
-                                errp) < 0) {
+    error = nbd_send_option_request(ioc, NBD_OPT_GO,
+                                    4 + len + 2 + 2 * info->request_sizes,
+                                    buf, errp);
+    g_free(buf);
+    if (error < 0) {
         return -1;
     }
 
This page took 0.026997 seconds and 4 git commands to generate.