]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nvme: fix FDP fdpcidx bounds check
authorliuxixin <gliuxen@gmail.com>
Thu, 28 May 2026 10:00:01 +0000 (18:00 +0800)
committerKeith Busch <kbusch@kernel.org>
Tue, 2 Jun 2026 12:20:57 +0000 (05:20 -0700)
The fdpcidx bounds check sets n = NUMFDPC + 1 but used > instead of >=,
incorrectly accepting fdp_idx when it equals n (i.e. NUMFDPC + 1).

Fixes: 30b5f20bb2dd ("nvme: register fdp parameters with the block layer")
Reviewed-by: Nitesh Shetty <nj.shetty@samsung.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: liuxixin <gliuxen@gmail.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/core.c

index f69e3115d8cf9fe8ef1eaae35850dd6163399bd1..ea837b94d3e51e9f727e7ad0d92b1d58c0ac9830 100644 (file)
@@ -2261,7 +2261,7 @@ static int nvme_query_fdp_granularity(struct nvme_ctrl *ctrl,
        }
 
        n = le16_to_cpu(h->numfdpc) + 1;
-       if (fdp_idx > n) {
+       if (fdp_idx >= n) {
                dev_warn(ctrl->device, "FDP index:%d out of range:%d\n",
                         fdp_idx, n);
                /* Proceed without registering FDP streams */