Skip to contentSkip to conversation

be2iscsi: Fix memory leak in beiscsi_alloc_mem()

PATCH Applied Maurizio Lombardi 4 participants 6 messages Oct 1, 2015 – Feb 11, 2016 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 be2iscsi: Fix memory leak in beiscsi_alloc_mem()

In case of error, the memory allocated for phwi_ctrlr was not freed.

---
 drivers/scsi/be2iscsi/be_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/be2iscsi/be_main.c +3 -1
index 7a6dbfb..360aa88 100644
@@ -2706,8 +2706,10 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba)
 	phwi_ctrlr->wrb_context = kzalloc(sizeof(struct hwi_wrb_context) *
 					  phba->params.cxns_per_ctrl,
 					  GFP_KERNEL);
-	if (!phwi_ctrlr->wrb_context)
+	if (!phwi_ctrlr->wrb_context) {
+		kfree(phba->phwi_ctrlr);
 		return -ENOMEM;
+	}
 
 	phba->init_mem = kcalloc(SE_MEM_MAX, sizeof(*mem_descr),
 				 GFP_KERNEL);
Signature · 1 line
Maurizio Lombardi
#1 lore raw

ping.

Quoted 24 lines · Maurizio Lombardi

In case of error, the memory allocated for phwi_ctrlr was not freed.

---
 drivers/scsi/be2iscsi/be_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/be2iscsi/be_main.c +3 -1
index 7a6dbfb..360aa88 100644
@@ -2706,8 +2706,10 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba)
 	phwi_ctrlr->wrb_context = kzalloc(sizeof(struct hwi_wrb_context) *
 					  phba->params.cxns_per_ctrl,
 					  GFP_KERNEL);
-	if (!phwi_ctrlr->wrb_context)
+	if (!phwi_ctrlr->wrb_context) {
+		kfree(phba->phwi_ctrlr);
 		return -ENOMEM;
+	}
 
 	phba->init_mem = kcalloc(SE_MEM_MAX, sizeof(*mem_descr),
 				 GFP_KERNEL);
Reviewed-by
#2 lore raw
Quoted 24 lines · Maurizio Lombardi

ping.

Quoted 21 lines · Maurizio Lombardi

In case of error, the memory allocated for phwi_ctrlr was not freed.

---
 drivers/scsi/be2iscsi/be_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/be2iscsi/be_main.c +3 -1
index 7a6dbfb..360aa88 100644
@@ -2706,8 +2706,10 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba)
 	phwi_ctrlr->wrb_context = kzalloc(sizeof(struct hwi_wrb_context) *
 					  phba->params.cxns_per_ctrl,
 					  GFP_KERNEL);
-	if (!phwi_ctrlr->wrb_context)
+	if (!phwi_ctrlr->wrb_context) {
+		kfree(phba->phwi_ctrlr);
 		return -ENOMEM;
+	}
 
Quoted 7 lines

drivers/scsi/be2iscsi/be_main.c static int beiscsi_alloc_mem(struct beiscsi_hba *phba) · line 2715

Quoted 3 lines
drivers/scsi/be2iscsi/be_main.c +0 -0
 	phba->init_mem = kcalloc(SE_MEM_MAX, sizeof(*mem_descr),
 				 GFP_KERNEL);

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 10 lines
Johannes Thumshirn                                          Storage
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
In reply to Maurizio Lombardi
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Maurizio" == Maurizio Lombardi <[email protected]> writes:

Jitendra,

Please review.

Quoted 24 lines

In case of error, the memory allocated for phwi_ctrlr was not freed.

---
 drivers/scsi/be2iscsi/be_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/be2iscsi/be_main.c +3 -1
index 7a6dbfb..360aa88 100644
@@ -2706,8 +2706,10 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba)
 	phwi_ctrlr->wrb_context = kzalloc(sizeof(struct hwi_wrb_context) *
 					  phba->params.cxns_per_ctrl,
 					  GFP_KERNEL);
-	if (!phwi_ctrlr->wrb_context)
+	if (!phwi_ctrlr->wrb_context) {
+		kfree(phba->phwi_ctrlr);
 		return -ENOMEM;
+	}
 
 	phba->init_mem = kcalloc(SE_MEM_MAX, sizeof(*mem_descr),
 				 GFP_KERNEL);
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
Reviewed-by
#5 lore raw
In reply to a message not in the archive

In case of error, the memory allocated for phwi_ctrlr was not freed.

---
 drivers/scsi/be2iscsi/be_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/be2iscsi/be_main.c +3 -1
index 7a6dbfb..360aa88 100644
@@ -2706,8 +2706,10 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba)
        phwi_ctrlr->wrb_context = kzalloc(sizeof(struct hwi_wrb_context) *
                                          phba->params.cxns_per_ctrl,
                                          GFP_KERNEL);
-       if (!phwi_ctrlr->wrb_context)
+       if (!phwi_ctrlr->wrb_context) {
+               kfree(phba->phwi_ctrlr);
                return -ENOMEM;
+       }
 
        phba->init_mem = kcalloc(SE_MEM_MAX, sizeof(*mem_descr),
                                 GFP_KERNEL);

--
Maurizio Lombardi

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Thanks,

JB

#6 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Jitendra" == Jitendra Bhivare <[email protected]> writes:

Jitendra> In case of error, the memory allocated for phwi_ctrlr was not Jitendra> freed.

Applied to 4.6/scsi-queue.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering