summaryrefslogtreecommitdiffstats
path: root/nbd
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2016-01-07 14:34:13 +0100
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 19:28:24 -0600
commit0258cf39c15e5554c4a3ae5bfedf97f51209355e (patch)
treeeaec2bbc3164cbe1ba496c0578d1f0dc1f8fa781 /nbd
parent724c7f447474459f9fac80b584229fb521f6b19d (diff)
downloadhqemu-0258cf39c15e5554c4a3ae5bfedf97f51209355e.zip
hqemu-0258cf39c15e5554c4a3ae5bfedf97f51209355e.tar.gz
nbd-server: do not exit on failed memory allocation
The amount of memory allocated in nbd_co_receive_request is driven by the NBD client (possibly a virtual machine). Parallel I/O can cause the server to allocate a large amount of memory; check for failures and return ENOMEM in that case. Cc: qemu-block@nongnu.org Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'nbd')
-rw-r--r--nbd/server.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/nbd/server.c b/nbd/server.c
index c41af0d..eead339 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -836,7 +836,11 @@ static ssize_t nbd_co_receive_request(NBDRequest *req, struct nbd_request *reque
goto out;
}
- req->data = blk_blockalign(client->exp->blk, request->len);
+ req->data = blk_try_blockalign(client->exp->blk, request->len);
+ if (req->data == NULL) {
+ rc = -ENOMEM;
+ goto out;
+ }
}
if (command == NBD_CMD_WRITE) {
TRACE("Reading %u byte(s)", request->len);
OpenPOWER on IntegriCloud