From: Kanchan Joshi Date: Tue, 6 May 2025 18:48:43 +0000 (+0530) Subject: nvme: fix incorrect sizeof X-Git-Tag: v6.16-rc1~216^2~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3c308b9d13ace45955e8406e3008f640f01faae;p=thirdparty%2Fkernel%2Flinux.git 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 --- diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index a9fb8cd544200..a8444d1e83982 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,