All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme-rdma: Fix a NULL deref when lesser io queues are allocated.
@ 2019-05-23  4:51 Nirranjan Kirubaharan
  2019-05-23  7:21 ` Max Gurtovoy
  0 siblings, 1 reply; 10+ messages in thread
From: Nirranjan Kirubaharan @ 2019-05-23  4:51 UTC (permalink / raw)


Return error -ENOMEM when nvmf target allocates lesser
io queues than the number of io queues requested by nvmf
initiator.

Signed-off-by: Nirranjan Kirubaharan <nirranjan at chelsio.com>
Reviewed-by: Potnuri Bharat Teja <bharat at chelsio.com>
---
 drivers/nvme/host/rdma.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index f383146e7d0f..187007d136cc 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -641,7 +641,7 @@ static int nvme_rdma_alloc_io_queues(struct nvme_rdma_ctrl *ctrl)
 {
 	struct nvmf_ctrl_options *opts = ctrl->ctrl.opts;
 	struct ib_device *ibdev = ctrl->device->dev;
-	unsigned int nr_io_queues;
+	unsigned int nr_io_queues, nr_req_queues;
 	int i, ret;
 
 	nr_io_queues = min(opts->nr_io_queues, num_online_cpus());
@@ -670,9 +670,16 @@ static int nvme_rdma_alloc_io_queues(struct nvme_rdma_ctrl *ctrl)
 		nr_io_queues += ctrl->io_queues[HCTX_TYPE_POLL];
 	}
 
+	nr_req_queues = nr_io_queues;
 	ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues);
 	if (ret)
 		return ret;
+	if (nr_io_queues < nr_req_queues) {
+		dev_err(ctrl->ctrl.device,
+			"alloc queues %u < req no of queues %u",
+			nr_io_queues, nr_req_queues);
+		return -ENOMEM;
+	}
 
 	ctrl->ctrl.queue_count = nr_io_queues + 1;
 	if (ctrl->ctrl.queue_count < 2)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-05-24 16:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-23  4:51 [PATCH] nvme-rdma: Fix a NULL deref when lesser io queues are allocated Nirranjan Kirubaharan
2019-05-23  7:21 ` Max Gurtovoy
2019-05-23  7:55   ` Nirranjan Kirubaharan
2019-05-23 11:14     ` Max Gurtovoy
2019-05-23 11:41       ` Nirranjan Kirubaharan
2019-05-23 14:35         ` Max Gurtovoy
2019-05-24  4:43           ` Nirranjan Kirubaharan
2019-05-24  6:24             ` Sagi Grimberg
2019-05-24 12:07               ` Max Gurtovoy
2019-05-24 16:11                 ` Sagi Grimberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.