From: Kanchan Joshi <joshi.k@samsung.com>
To: axboe@kernel.dk, kbusch@kernel.org, linux-nvme@lists.infradead.org
Cc: csander@purestorage.com, Kanchan Joshi <joshi.k@samsung.com>
Subject: [PATCH v2] nvme: fix incorrect sizeof
Date: Wed, 7 May 2025 00:18:43 +0530 [thread overview]
Message-ID: <20250506184843.25081-1-joshi.k@samsung.com> (raw)
In-Reply-To: CGME20250506185729epcas5p42c58afcb24ceb7be79babb63932677bb@epcas5p4.samsung.com
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 <csander@purestorage.com>
Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
---
changes since v1:
- add reported-by (Jens)
- expand commit description (Jens)
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 52331a14bce1..7c1b9f2bf0ae 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.25.1
next parent reply other threads:[~2025-05-06 23:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20250506185729epcas5p42c58afcb24ceb7be79babb63932677bb@epcas5p4.samsung.com>
2025-05-06 18:48 ` Kanchan Joshi [this message]
2025-05-06 19:47 ` [PATCH v2] nvme: fix incorrect sizeof Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250506184843.25081-1-joshi.k@samsung.com \
--to=joshi.k@samsung.com \
--cc=axboe@kernel.dk \
--cc=csander@purestorage.com \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox