nbd/server: nbd_negotiate: fix error path
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Fri, 2 Jun 2017 15:01:47 +0000 (18:01 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 15 Jun 2017 09:18:39 +0000 (11:18 +0200)
Current code will return 0 on this nbd_write fail, as rc is 0
after successful nbd_negotiate_options. Fix this.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20170602150150.258222-10-vsementsov@virtuozzo.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
nbd/server.c

index d52682741f0151474b9a7cd4437ad708df7064b6..c9ca84702151dd4eb7f83d9690f8427db9c00020 100644 (file)
@@ -607,7 +607,8 @@ static coroutine_fn int nbd_negotiate(NBDClient *client)
         stq_be_p(buf + 18, client->exp->size);
         stw_be_p(buf + 26, client->exp->nbdflags | myflags);
         len = client->no_zeroes ? 10 : sizeof(buf) - 18;
-        if (nbd_write(client->ioc, buf + 18, len, NULL) < 0) {
+        rc = nbd_write(client->ioc, buf + 18, len, NULL);
+        if (rc < 0) {
             LOG("write failed");
             goto fail;
         }