summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorYang Yingliang <yangyingliang@huawei.com>2022-11-10 23:11:29 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-01-18 11:30:22 +0100
commit2acd1ecc2e2a49286606a17f6ed24998df90f994 (patch)
treec56cced9b7bb695181f2a598ab38702e58960c0f /drivers
parente4ec2042899536b5a8f714b6eda4443d717f41bf (diff)
downloadlinux-stable-2acd1ecc2e2a49286606a17f6ed24998df90f994.tar.gz
linux-stable-2acd1ecc2e2a49286606a17f6ed24998df90f994.tar.bz2
linux-stable-2acd1ecc2e2a49286606a17f6ed24998df90f994.zip
scsi: hpsa: Fix error handling in hpsa_add_sas_host()
[ Upstream commit 4ef174a3ad9b5d73c1b6573e244ebba2b0d86eac ] hpsa_sas_port_add_phy() does: ... sas_phy_add() -> may return error here sas_port_add_phy() ... Whereas hpsa_free_sas_phy() does: ... sas_port_delete_phy() sas_phy_delete() ... If hpsa_sas_port_add_phy() returns an error, hpsa_free_sas_phy() can not be called to free the memory because the port and the phy have not been added yet. Replace hpsa_free_sas_phy() with sas_phy_free() and kfree() to avoid kernel crash in this case. Fixes: d04e62b9d63a ("hpsa: add in sas transport class") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Link: https://lore.kernel.org/r/20221110151129.394389-1-yangyingliang@huawei.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/hpsa.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 1a4fc8b8a9cd..392dfc8f3cbb 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -9700,7 +9700,8 @@ static int hpsa_add_sas_host(struct ctlr_info *h)
return 0;
free_sas_phy:
- hpsa_free_sas_phy(hpsa_sas_phy);
+ sas_phy_free(hpsa_sas_phy->phy);
+ kfree(hpsa_sas_phy);
free_sas_port:
hpsa_free_sas_port(hpsa_sas_port);
free_sas_node: