summaryrefslogtreecommitdiff
path: root/nbd/client.c
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>2017-07-26 23:42:09 -0300
committerEric Blake <eblake@redhat.com>2017-07-28 11:58:20 -0500
commit158b9aa568eabe614d37882dddc2eea534edc7ae (patch)
tree7dd7a5f22295c64bd63b0f968c99a6621c10da53 /nbd/client.c
parent3aabfec2c83da500ae52fc87ff3a0a60718022db (diff)
downloadqemu-158b9aa568eabe614d37882dddc2eea534edc7ae.tar.gz
nbd: fix memory leak in nbd_opt_go()
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é <f4bug@amsat.org> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20170727024224.22900-5-f4bug@amsat.org> [introduced in commit 8ecaeae8] Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'nbd/client.c')
-rw-r--r--nbd/client.c8
1 files 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;
}