From 0bb3618a993af825f950a6dc53e5925bb18feec0 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Tue, 11 Jul 2017 15:18:36 -0700 Subject: [PATCH] vhost_scsi: check for task allocation failure Change-Id: I03e63985907d7330373b1883652cd27a0cf466db Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/369081 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Pawel Wodkowski Reviewed-by: Ben Walker --- lib/vhost/vhost_scsi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/vhost/vhost_scsi.c b/lib/vhost/vhost_scsi.c index 2419e4605..336f199dc 100644 --- a/lib/vhost/vhost_scsi.c +++ b/lib/vhost/vhost_scsi.c @@ -1001,6 +1001,12 @@ alloc_task_pool(struct spdk_vhost_scsi_dev *svdev) for (i = 0; i < task_cnt; ++i) { task = spdk_dma_zmalloc(sizeof(*task), SPDK_CACHE_LINE_SIZE, NULL); + if (task == NULL) { + SPDK_ERRLOG("Controller %s: Failed to allocate task\n", svdev->vdev.name); + free_task_pool(svdev); + return -1; + } + rc = spdk_ring_enqueue(svdev->task_pool, (void **)&task, 1); if (rc != 1) { SPDK_ERRLOG("Controller %s: Failed to alloc %"PRIu32" vhost scsi tasks\n", svdev->vdev.name,