Commit fda34a5d authored by Yang Yingliang's avatar Yang Yingliang Committed by Martin K. Petersen

scsi: hpsa: Fix possible memory leak in hpsa_add_sas_device()

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: d04e62b9 ("hpsa: add in sas transport class")
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20221111043012.1074466-1-yangyingliang@huawei.comSigned-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 4ef174a3
...@@ -9823,10 +9823,12 @@ static int hpsa_add_sas_device(struct hpsa_sas_node *hpsa_sas_node, ...@@ -9823,10 +9823,12 @@ static int hpsa_add_sas_device(struct hpsa_sas_node *hpsa_sas_node,
rc = hpsa_sas_port_add_rphy(hpsa_sas_port, rphy); rc = hpsa_sas_port_add_rphy(hpsa_sas_port, rphy);
if (rc) if (rc)
goto free_sas_port; goto free_sas_rphy;
return 0; return 0;
free_sas_rphy:
sas_rphy_free(rphy);
free_sas_port: free_sas_port:
hpsa_free_sas_port(hpsa_sas_port); hpsa_free_sas_port(hpsa_sas_port);
device->sas_port = NULL; device->sas_port = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment