From: liuxixin Date: Thu, 28 May 2026 10:00:01 +0000 (+0800) Subject: nvme: fix FDP fdpcidx bounds check X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=0967074f6830718fd2597404ef119bddd0dbfd00;p=thirdparty%2Fkernel%2Flinux.git nvme: fix FDP fdpcidx bounds check 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 Reviewed-by: Christoph Hellwig Signed-off-by: liuxixin Signed-off-by: Keith Busch --- diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index f69e3115d8cf9..ea837b94d3e51 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -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 */