Skip to content

Commit

Permalink
scsi: hpsa: Fix possible memory leak in hpsa_add_sas_device()
Browse files Browse the repository at this point in the history
[ Upstream commit fda34a5 ]

If hpsa_sas_port_add_rphy() returns an error, the 'rphy' allocated in
sas_end_device_alloc() needs to be freed. Address this by calling
sas_rphy_free() in the error path.

Fixes: d04e62b ("hpsa: add in sas transport class")
Signed-off-by: Yang Yingliang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Martin K. Petersen <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
Yang Yingliang authored and gregkh committed Jan 17, 2023
1 parent f8113d5 commit aca4dc9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/scsi/hpsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -9489,10 +9489,12 @@ static int hpsa_add_sas_device(struct hpsa_sas_node *hpsa_sas_node,

rc = hpsa_sas_port_add_rphy(hpsa_sas_port, rphy);
if (rc)
goto free_sas_port;
goto free_sas_rphy;

return 0;

free_sas_rphy:
sas_rphy_free(rphy);
free_sas_port:
hpsa_free_sas_port(hpsa_sas_port);
device->sas_port = NULL;
Expand Down

0 comments on commit aca4dc9

Please sign in to comment.