qemu-nbd: Fix a memleak in qemu_nbd_client_list()
PATCH 1/1 qemu-nbd: Fix a memleak in qemu_nbd_client_list()
When the qio_channel_socket_connect_sync() fails
we should goto 'out' label to free the 'sioc' instead of return.
Reported-by Euler Robot <[email protected]>
Signed-off-by Alex Chen <[email protected]>
--- qemu-nbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qemu-nbd.c +1 -1
@@ -181,7 +181,7 @@ static int qemu_nbd_client_list(SocketAddress *saddr, QCryptoTLSCreds *tls, sioc =qio_channel_socket_new ();if (qio_channel_socket_connect_sync (sioc, saddr, &err) <0 ) {error_report_err (err); -return EXIT_FAILURE ; + goto out; } rc =nbd_receive_export_list (QIO_CHANNEL (sioc), tls, hostname, &list, &err);
Signature · 1 line
2.19.1
Quoted 5 lines · Alex Chen
When the
qio_channel_socket_connect_sync()fails
we should goto 'out' label to free the 'sioc' instead of return.Reported-by Euler Robot <[email protected]>Signed-off-by Alex Chen <[email protected]>
Reviewed-by Alberto Garcia <[email protected]>
Berto
Quoted 8 lines · Alex Chen
When the
qio_channel_socket_connect_sync()fails
we should goto 'out' label to free the 'sioc' instead of return.Reported-by Euler Robot <[email protected]>Signed-off-by Alex Chen <[email protected]>--- qemu-nbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
A local leak, but the only caller of qemu_nbd_client_list() is main() which returns the value and thereby exits the program, so it is inconsequential in the bigger picture. I'll defer this to 6.0, and pick it up through my NBD tree once that opens.
Quoted 15 lines
qemu-nbd.c +1
-1@@ -181,7 +181,7 @@ static int qemu_nbd_client_list(SocketAddress *saddr, QCryptoTLSCreds *tls, sioc =qio_channel_socket_new ();if (qio_channel_socket_connect_sync (sioc, saddr, &err) <0 ) {error_report_err (err); -return EXIT_FAILURE ; + goto out; } rc =nbd_receive_export_list (QIO_CHANNEL (sioc), tls, hostname, &list, &err);
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org