* [PATCH] nvme: clear caller pointer on identify failure
@ 2024-03-06 14:25 Keith Busch
2024-03-06 14:27 ` Christoph Hellwig
2024-03-06 17:45 ` Chaitanya Kulkarni
0 siblings, 2 replies; 3+ messages in thread
From: Keith Busch @ 2024-03-06 14:25 UTC (permalink / raw
To: linux-nvme; +Cc: hch, shinichiro.kawasaki, Keith Busch
From: Keith Busch <kbusch@kernel.org>
The memory allocated for the identifification is freed on failure. Set
it to NULL so the caller doesn't have a pointer to that freed address.
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
drivers/nvme/host/core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index c4d928585ce35..2baf5786a92fe 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1403,8 +1403,10 @@ static int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id)
error = nvme_submit_sync_cmd(dev->admin_q, &c, *id,
sizeof(struct nvme_id_ctrl));
- if (error)
+ if (error) {
kfree(*id);
+ *id = NULL;
+ }
return error;
}
@@ -1533,6 +1535,7 @@ int nvme_identify_ns(struct nvme_ctrl *ctrl, unsigned nsid,
if (error) {
dev_warn(ctrl->device, "Identify namespace failed (%d)\n", error);
kfree(*id);
+ *id = NULL;
}
return error;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] nvme: clear caller pointer on identify failure
2024-03-06 14:25 [PATCH] nvme: clear caller pointer on identify failure Keith Busch
@ 2024-03-06 14:27 ` Christoph Hellwig
2024-03-06 17:45 ` Chaitanya Kulkarni
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2024-03-06 14:27 UTC (permalink / raw
To: Keith Busch; +Cc: linux-nvme, hch, shinichiro.kawasaki, Keith Busch
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nvme: clear caller pointer on identify failure
2024-03-06 14:25 [PATCH] nvme: clear caller pointer on identify failure Keith Busch
2024-03-06 14:27 ` Christoph Hellwig
@ 2024-03-06 17:45 ` Chaitanya Kulkarni
1 sibling, 0 replies; 3+ messages in thread
From: Chaitanya Kulkarni @ 2024-03-06 17:45 UTC (permalink / raw
To: Keith Busch, linux-nvme@lists.infradead.org
Cc: hch@lst.de, shinichiro.kawasaki@wdc.com, Keith Busch
On 3/6/2024 6:25 AM, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> The memory allocated for the identifification is freed on failure. Set
> it to NULL so the caller doesn't have a pointer to that freed address.
>
> Signed-off-by: Keith Busch <kbusch@kernel.org>
> ---
LGTM.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
-ck
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-06 17:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-06 14:25 [PATCH] nvme: clear caller pointer on identify failure Keith Busch
2024-03-06 14:27 ` Christoph Hellwig
2024-03-06 17:45 ` Chaitanya Kulkarni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).