[PATCH] nvme: remove bogus check in nvme_pr_read_keys()

Dan Carpenter dan.carpenter at linaro.org
Sat Mar 21 03:26:25 PDT 2026


This check for if (rse_len > U32_MAX) is confusing because if
rse_len is > INT_MAX, that will trigger a WARN() in kvzalloc().
Fortunately, the caller blkdev_pr_read_keys(), puts a limit on num_keys.
The number of keys can't be more than PR_KEYS_MAX (65536) and the
condition is impossible.

Delete the confusing, dead code.

Signed-off-by: Dan Carpenter <dan.carpenter at linaro.org>
---
 drivers/nvme/host/pr.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/nvme/host/pr.c b/drivers/nvme/host/pr.c
index fe7dbe264815..abab2746f0f8 100644
--- a/drivers/nvme/host/pr.c
+++ b/drivers/nvme/host/pr.c
@@ -239,9 +239,6 @@ static int nvme_pr_read_keys(struct block_device *bdev,
 	 * enough to get enough keys to fill the return keys buffer.
 	 */
 	rse_len = struct_size(rse, regctl_eds, num_keys);
-	if (rse_len > U32_MAX)
-		return -EINVAL;
-
 	rse = kvzalloc(rse_len, GFP_KERNEL);
 	if (!rse)
 		return -ENOMEM;
-- 
2.51.0




More information about the Linux-nvme mailing list