Skip to content

Commit

Permalink
block/nvme: nvme_process_completion() fix bound for cid
Browse files Browse the repository at this point in the history
NVMeQueuePair::reqs has length NVME_NUM_REQS, which less than
NVME_QUEUE_SIZE by 1.

Fixes: 1086e95 ("block/nvme: switch to a NVMeRequest freelist")
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Maksim Davydov <davydov-max@yandex-team.ru>
Message-id: 20231017125941.810461-5-vsementsov@yandex-team.ru
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit cc8fb0c)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
Vladimir Sementsov-Ogievskiy authored and Michael Tokarev committed Nov 9, 2023
1 parent a89c8b9 commit 1f560fa
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions block/nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,10 @@ static bool nvme_process_completion(NVMeQueuePair *q)
q->cq_phase = !q->cq_phase;
}
cid = le16_to_cpu(c->cid);
if (cid == 0 || cid > NVME_QUEUE_SIZE) {
warn_report("NVMe: Unexpected CID in completion queue: %"PRIu32", "
"queue size: %u", cid, NVME_QUEUE_SIZE);
if (cid == 0 || cid > NVME_NUM_REQS) {
warn_report("NVMe: Unexpected CID in completion queue: %" PRIu32
", should be within: 1..%u inclusively", cid,
NVME_NUM_REQS);
continue;
}
trace_nvme_complete_command(s, q->index, cid);
Expand Down

0 comments on commit 1f560fa

Please sign in to comment.