public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: hpsa: fix possible memory leak in hpsa_add_sas_device()
@ 2022-11-11  4:30 Yang Yingliang
  2022-11-26  0:18 ` Martin K. Petersen
  2022-12-01  3:45 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Yang Yingliang @ 2022-11-11  4:30 UTC (permalink / raw)
  To: linux-scsi, storagedev; +Cc: don.brace, jejb, martin.petersen, yangyingliang

If hpsa_sas_port_add_rphy() returns error, the 'rphy' allocated
in sas_end_device_alloc() need be free, fix this by calling
sas_rphy_free() in the error path.

Fixes: d04e62b9d63a ("hpsa: add in sas transport class")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/scsi/hpsa.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index b3f195467e97..1d2cad257dab 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -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);
 	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;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-01  3:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-11  4:30 [PATCH] scsi: hpsa: fix possible memory leak in hpsa_add_sas_device() Yang Yingliang
2022-11-26  0:18 ` Martin K. Petersen
2022-12-01  3:45 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox