Skip to contentSkip to conversation

scsi: aic94xx: Add a missing call to kfree

PATCH Applied Quentin Lambert 3 participants 3 messages Nov 25, 2016 – Nov 29, 2016

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

PATCH v2 1/1 scsi: aic94xx: Add a missing call to kfree

Most error branches following the call to kzalloc contain a call to kfree. This patch add these calls where they are missing and set the relevant pointers to NULL.

This issue was found with Hector.

---
v2: set the point to NULL after having freed it

 drivers/scsi/aic94xx/aic94xx_hwi.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/aic94xx/aic94xx_hwi.c +4 -1
@@ -228,8 +228,11 @@ static int asd_init_scbs(struct asd_ha_s
 	bitmap_bytes = (asd_ha->seq.tc_index_bitmap_bits+7)/8;
 	bitmap_bytes = BITS_TO_LONGS(bitmap_bytes*8)*sizeof(unsigned long);
 	asd_ha->seq.tc_index_bitmap = kzalloc(bitmap_bytes, GFP_KERNEL);
-	if (!asd_ha->seq.tc_index_bitmap)
+	if (!asd_ha->seq.tc_index_bitmap) {
+		kfree(asd_ha->seq.tc_index_array);
+		asd_ha->seq.tc_index_array = NULL;
 		return -ENOMEM;
+	}
 
 	spin_lock_init(&seq->tc_index_lock);
 
#2 lore raw
In reply to Quentin Lambert
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Quentin" = Quentin Lambert <[email protected]> writes:

Quentin> Most error branches following the call to kzalloc contain a Quentin> call to kfree. This patch add these calls where they are Quentin> missing and set the relevant pointers to NULL.

Applied to 4.10/scsi-queue.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering