[RFC PATCH v2 09/13] nvme: Check the DSM range buffer against PAGE_SIZE_MIN

Eric Curtin ericcurtin17 at gmail.com
Tue Dec 1 19:16:30 PST 2026


From: Ryan Roberts <ryan.roberts at arm.com>

The BUILD_BUG_ON() in nvme_init_ctrl() verifies that the discard page
can hold NVME_DSM_MAX_RANGES DSM ranges. PAGE_SIZE is not a compile-time
constant with arm64 boot-time page size selection, so compare against
PAGE_SIZE_MIN, the smallest page size that can be in use.

Signed-off-by: Ryan Roberts <ryan.roberts at arm.com>
Signed-off-by: Eric Curtin <eric.curtin at docker.com>
---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index f43582e5f6c4..8cf78eff9cff 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -5295,7 +5295,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
 	ctrl->io_timeout = NVME_IO_TIMEOUT;
 
 	BUILD_BUG_ON(NVME_DSM_MAX_RANGES * sizeof(struct nvme_dsm_range) >
-			PAGE_SIZE);
+			PAGE_SIZE_MIN);
 	ctrl->discard_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
 	if (!ctrl->discard_page) {
 		ret = -ENOMEM;



More information about the Linux-nvme mailing list