nvme: fix incorrect sizeof
A message that is not in the archive (sent off-list or not yet received): CGME20250506185729epcas5p42c58afcb24ceb7be79babb63932677bb@epcas5p4.samsung.com
PATCH v2 1/1 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.
---
changes since v1:
- add reported-by (Jens)
- expand commit description (Jens)
drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
@@ -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,
Signature · 1 line
2.25.1
Jens Axboe
maintainerQuoted 6 lines · Kanchan Joshi
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.
For some reason this isn't on lore, I hand applied it.
Signature · 1 line
Jens Axboe