From: Caleb Sander Mateos Date: Tue, 6 May 2025 17:54:12 +0000 (-0600) Subject: nvme: fix write_stream_granularity initialization X-Git-Tag: for-6.16/block-20250523~57 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=86b6e0bd1a69efd0ed408997e0adfb85df96a0c7;p=linux-block.git nvme: fix write_stream_granularity initialization write_stream_granularity is set to max(info->runs, U32_MAX), which means that any RUNS value less than 2 ** 32 becomes U32_MAX, and any larger value is silently truncated to an unsigned int. Use min() instead to provide the correct semantics, capping RUNS values at U32_MAX. Signed-off-by: Caleb Sander Mateos Fixes: 30b5f20bb2dd ("nvme: register fdp parameters with the block layer") Reviewed-by: Keith Busch Link: https://lore.kernel.org/r/20250506175413.1936110-1-csander@purestorage.com Signed-off-by: Jens Axboe --- diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 52331a14bce1..a9fb8cd54420 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2392,7 +2392,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns, lim.max_write_streams = ns->head->nr_plids; if (lim.max_write_streams) - lim.write_stream_granularity = max(info->runs, U32_MAX); + lim.write_stream_granularity = min(info->runs, U32_MAX); else lim.write_stream_granularity = 0;