Skip to contentSkip to conversation

NVMe: Protect against badly formatted CQEs

PATCH New Keith Busch 1 participant 1 message Apr 25, 2014

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

PATCH 1/1 NVMe: Protect against badly formatted CQEs

If a misbehaving device posts a CQE with a command id < depth but for one that was never allocated, the command info will have a callback function set to NULL and we don't want to try invoking that.

Signed-off-by Keith Busch <keith.busch at intel.com>
---
 drivers/block/nvme-core.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/block/nvme-core.c +3 -2
index efa9c8f..d4aa4ff 100644
@@ -247,8 +247,9 @@ static void *free_cmdid(struct nvme_queue *nvmeq, int cmdid,
 	void *ctx;
 	struct nvme_cmd_info *info = nvme_cmd_info(nvmeq);
 
-	if (cmdid >= nvmeq->q_depth) {
-		*fn = special_completion;
+	if (cmdid >= nvmeq->q_depth || !info[cmdid].fn) {
+		if (fn)
+			*fn = special_completion;
 		return CMD_CTX_INVALID;
 	}
 	if (fn)
Signature · 1 line
1.7.10.4