Skip to contentSkip to conversation

nvme: fix sqhd reference when admin queue connect fails

PATCH New James Smart 1 participant 1 message Sep 21, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: fix sqhd reference when admin queue connect fails

Fix bug in sqhd patch.

It wasn't the sq that was at risk. In the case where the admin queue Connect command fails, the sq->size field is not set. Therefore, this becomes a divide by zero error.

Add a quick check to bypass under this failure condition.

Signed-off-by James Smart <james.smart at broadcom.com>
---
 drivers/nvme/target/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/target/core.c +2 -1
index 8c86c258d2e8..8b6175d0531a 100644
@@ -390,7 +390,8 @@ static void __nvmet_req_complete(struct nvmet_req *req, u16 status)
 	if (status)
 		nvmet_set_status(req, status);
 
-	req->sq->sqhd = (req->sq->sqhd + 1) % req->sq->size;
+	if (req->sq->size)
+		req->sq->sqhd = (req->sq->sqhd + 1) % req->sq->size;
 	req->rsp->sq_head = cpu_to_le16(req->sq->sqhd);
 	req->rsp->sq_id = cpu_to_le16(req->sq->qid);
 	req->rsp->command_id = req->cmd->common.command_id;
Signature · 1 line
2.13.1