diff options
author | Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> | 2023-11-06 15:00:28 +0000 |
---|---|---|
committer | Michael Tokarev <mjt@tls.msk.ru> | 2023-11-07 19:22:08 +0300 |
commit | 0d7c40a1e2a8c6368614ea58b24c845e1e9522de (patch) | |
tree | 1613a24d9fdaf7cb2387d27953398a060c0b2800 | |
parent | 26bb3ab8ffd6d7f3c9095ffeec17d2a929f5c6ea (diff) |
block/nvme: nvme_process_completion() fix bound for cid
NVMeQueuePair::reqs has length NVME_NUM_REQS, which less than
NVME_QUEUE_SIZE by 1.
Fixes: 1086e95da17050 ("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 cc8fb0c3ae3c950eb40e969607e17ff16a7519ac)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
-rw-r--r-- | block/nvme.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/block/nvme.c b/block/nvme.c index 656624c585..14d01a5ea9 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -419,9 +419,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); |