From f3c308b9d13ace45955e8406e3008f640f01faae Mon Sep 17 00:00:00 2001 From: Kanchan Joshi Date: Wed, 7 May 2025 00:18:43 +0530 Subject: [PATCH] nvme: fix incorrect sizeof The plid array, head->plids, is meant to store placement IDs, each of type u16. But its size has been incorrectly calculated, as the size of the pointer is being used instead of the size of the object it points to. Use the sizeof(*head->plids) in kcalloc so that we don't allocate extra. Fixes: 38e8397dde63 ("nvme: use fdp streams if write stream is provided") Reported-by: Caleb Sander Mateos Signed-off-by: Kanchan Joshi Reviewed-by: Caleb Sander Mateos Signed-off-by: Jens Axboe --- 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 a9fb8cd54420..a8444d1e8398 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2296,7 +2296,7 @@ static int nvme_query_fdp_info(struct nvme_ns *ns, struct nvme_ns_info *info) if (!head->nr_plids) goto free; - head->plids = kcalloc(head->nr_plids, sizeof(head->plids), + head->plids = kcalloc(head->nr_plids, sizeof(*head->plids), GFP_KERNEL); if (!head->plids) { dev_warn(ctrl->device, -- 2.50.1