From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daYlF-0005JF-K2 for qemu-devel@nongnu.org; Wed, 26 Jul 2017 22:42:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daYlC-0007io-1h for qemu-devel@nongnu.org; Wed, 26 Jul 2017 22:42:49 -0400 Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 26 Jul 2017 23:42:09 -0300 Message-Id: <20170727024224.22900-5-f4bug@amsat.org> In-Reply-To: <20170727024224.22900-1-f4bug@amsat.org> References: <20170727024224.22900-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH for 2.10 v2 04/20] nbd: fix memory leak in nbd_opt_go() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Eric Blake Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, qemu-trivial@nongnu.org, qemu-block@nongnu.org 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é Reviewed-by: Eric Blake --- nbd/client.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nbd/client.c b/nbd/client.c index 509ed5e4ba..0a17de80b5 100644 --- a/nbd/client.c +++ b/nbd/client.c @@ -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; } -- 2.13.3