Skip to contentSkip to conversation

mpt2sas: Fix leak on mpt2sas_base_attach() error path

PATCH In review Roland Dreier 2 participants 2 messages Dec 1, 2011 – Dec 2, 2011 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mpt2sas: Fix leak on mpt2sas_base_attach() error path

From: Roland Dreier <[email protected]>

Commit 911ae9434f83 ("[SCSI] mpt2sas: Added NUNA IO support in driver which uses multi-reply queue support of the HBA") added new allocations to the beginning of mpt2sas_base_attach(), which means directly returning an error on failure of mpt2sas_base_map_resources() will leak those allocations.

Fix this by doing "goto out_free_resources" in this place too, as the rest of the function does.

---
 drivers/scsi/mpt2sas/mpt2sas_base.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/mpt2sas/mpt2sas_base.c +1 -1
index beda04a..a7b2a16 100644
@@ -4206,7 +4206,7 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
 
 	r = mpt2sas_base_map_resources(ioc);
 	if (r)
-		return r;
+		goto out_free_resources;
 
 	if (ioc->is_warpdrive) {
 		ioc->reply_post_host_index[0] =
Signature · 1 line
1.7.5.4
#1 lore raw

This patch seem to be fine.
Please consider this patch as acked by me.

Regards,
Nagalakshmi

-----Original Message-----
From: Roland Dreier [mailto:[email protected]] On Behalf Of Roland Dreier
Sent: Thursday, December 01, 2011 6:44 AM
To: James E.J. Bottomley
Cc: Nandigama, Nagalakshmi; [email protected]
Subject: [PATCH] [SCSI] mpt2sas: Fix leak on mpt2sas_base_attach() error path

From: Roland Dreier <[email protected]>

Commit 911ae9434f83 ("[SCSI] mpt2sas: Added NUNA IO support in driver which uses multi-reply queue support of the HBA") added new allocations to the beginning of mpt2sas_base_attach(), which means directly returning an error on failure of mpt2sas_base_map_resources() will leak those allocations.

Fix this by doing "goto out_free_resources" in this place too, as the rest of the function does.

---
 drivers/scsi/mpt2sas/mpt2sas_base.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/mpt2sas/mpt2sas_base.c +1 -1
index beda04a..a7b2a16 100644
@@ -4206,7 +4206,7 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
 
 	r = mpt2sas_base_map_resources(ioc);
 	if (r)
-		return r;
+		goto out_free_resources;
 
 	if (ioc->is_warpdrive) {
 		ioc->reply_post_host_index[0] =
Signature · 1 line
1.7.5.4