nvme: clear caller pointer on identify failure
PATCH 1/1 nvme: clear caller pointer on identify failure
From: Keith Busch <[email protected]>
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 <[email protected]>
--- drivers/nvme/host/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +4 -1
@@ -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; }
Signature · 1 line
2.34.1
Looks good:
Reviewed-by Christoph Hellwig <[email protected]>
Quoted 7 lines · Keith Busch
From: Keith Busch <[email protected]>
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 <[email protected]>---
LGTM.
Reviewed-by Chaitanya Kulkarni <[email protected]>
-ck