diff --git a/block/nbd-client.c b/block/nbd-client.c index 3dfae1da09..9156093dc0 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -337,7 +337,12 @@ static void nbd_teardown_connection(NbdClientSession *client) void nbd_client_session_close(NbdClientSession *client) { + if (!client->bs) { + return; + } + nbd_teardown_connection(client); + client->bs = NULL; } int nbd_client_session_init(NbdClientSession *client, BlockDriverState *bs,