Skip to content

Commit 7e80eb7

Browse files
committed
nvme: clear caller pointer on identify failure
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 <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 8d0d244 commit 7e80eb7

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
@@ -1403,8 +1403,10 @@ static int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id)
14031403

14041404
error = nvme_submit_sync_cmd(dev->admin_q, &c, *id,
14051405
sizeof(struct nvme_id_ctrl));
1406-
if (error)
1406+
if (error) {
14071407
kfree(*id);
1408+
*id = NULL;
1409+
}
14081410
return error;
14091411
}
14101412

@@ -1533,6 +1535,7 @@ int nvme_identify_ns(struct nvme_ctrl *ctrl, unsigned nsid,
15331535
if (error) {
15341536
dev_warn(ctrl->device, "Identify namespace failed (%d)\n", error);
15351537
kfree(*id);
1538+
*id = NULL;
15361539
}
15371540
return error;
15381541
}

0 commit comments

Comments
 (0)