summaryrefslogtreecommitdiff
path: root/drivers/nvme
diff options
context:
space:
mode:
authorKeith Busch <kbusch@kernel.org>2024-03-06 06:20:30 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-09-04 13:14:56 +0200
commitd037a1d1f55d7bc83caf7575273ad69a8590c07d (patch)
treefe8da0de0518c0bd087bdf19d9f6ac356879c5c0 /drivers/nvme
parenta98c91a49e596364232038ae8be7a0830eb0a8e5 (diff)
downloadlinux-d037a1d1f55d7bc83caf7575273ad69a8590c07d.tar.gz
linux-d037a1d1f55d7bc83caf7575273ad69a8590c07d.tar.bz2
linux-d037a1d1f55d7bc83caf7575273ad69a8590c07d.zip
nvme: clear caller pointer on identify failure
[ Upstream commit 7e80eb792bd7377a20f204943ac31c77d859be89 ] The memory allocated for the identification is freed on failure. Set it to NULL so the caller doesn't have a pointer to that freed address. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/nvme')
-rw-r--r--drivers/nvme/host/core.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 9144ed14b074..0676637e1eab 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1080,8 +1080,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;
}
@@ -1193,6 +1195,7 @@ static int nvme_identify_ns(struct nvme_ctrl *ctrl,
if (error) {
dev_warn(ctrl->device, "Identify namespace failed (%d)\n", error);
kfree(*id);
+ *id = NULL;
}
return error;