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: 38e8397dde ("nvme: use fdp streams if write stream is provided")
Reported-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Kanchan Joshi 2025-05-07 00:18:43 +05:30 committed by Jens Axboe
parent 86b6e0bd1a
commit f3c308b9d1

View File

@ -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,