lib: Return instead of abort() in nbd

Return NULL on resource failure (calloc) instead of
abort()'ing in static nbd function and check result
returning an errno, in that case, further up the call
chain.

Change-Id: If95f8db745fa77c76c415a1aa54c5338c270628f
Signed-off-by: Lance Hartmann <lance.hartmann@oracle.com>
Reviewed-on: https://review.gerrithub.io/403588
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Lance Hartmann 2018-03-12 18:16:26 -04:00 committed by Jim Harris
parent abd86265d3
commit 5c36200d90

View File

@ -229,8 +229,7 @@ spdk_get_nbd_io(struct spdk_nbd_disk *nbd)
io = calloc(1, sizeof(*io)); io = calloc(1, sizeof(*io));
if (!io) { if (!io) {
SPDK_ERRLOG("Unable to get nbd_io\n"); return NULL;
abort();
} }
io->nbd = nbd; io->nbd = nbd;
@ -509,6 +508,9 @@ spdk_nbd_io_recv_internal(struct spdk_nbd_disk *nbd)
if (nbd->io_in_recv == NULL) { if (nbd->io_in_recv == NULL) {
nbd->io_in_recv = spdk_get_nbd_io(nbd); nbd->io_in_recv = spdk_get_nbd_io(nbd);
if (!nbd->io_in_recv) {
return -ENOMEM;
}
} }
io = nbd->io_in_recv; io = nbd->io_in_recv;