Skip to content

Commit d2e2556

Browse files
nvme: clear caller pointer on identify failure
JIRA: https://issues.redhat.com/browse/RHEL-25547 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> (cherry picked from commit 7e80eb7) Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
1 parent 5db2347 commit d2e2556

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/nvme/host/core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1423,8 +1423,10 @@ static int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id)
14231423

14241424
error = nvme_submit_sync_cmd(dev->admin_q, &c, *id,
14251425
sizeof(struct nvme_id_ctrl));
1426-
if (error)
1426+
if (error) {
14271427
kfree(*id);
1428+
*id = NULL;
1429+
}
14281430
return error;
14291431
}
14301432

@@ -1553,6 +1555,7 @@ int nvme_identify_ns(struct nvme_ctrl *ctrl, unsigned nsid,
15531555
if (error) {
15541556
dev_warn(ctrl->device, "Identify namespace failed (%d)\n", error);
15551557
kfree(*id);
1558+
*id = NULL;
15561559
}
15571560
return error;
15581561
}

0 commit comments

Comments
 (0)