Skip to contentSkip to conversation

scsi: aic94xx: Add a missing call to kfree

PATCH In review Quentin Lambert 2 participants 2 messages Nov 19, 2016 – Nov 22, 2016

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

PATCH 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.

This issue was found with Hector.

---
 drivers/scsi/aic94xx/aic94xx_hwi.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/aic94xx/aic94xx_hwi.c +3 -1
@@ -228,8 +228,10 @@ 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);
 		return -ENOMEM;
+	}
 
 	spin_lock_init(&seq->tc_index_lock);
 
#1 lore raw
Quoted 5 lines · Quentin Lambert

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

This issue was found with Hector.

Hi Quentin,
most error branches also do set the freed pointer to NULL, please do the same.

tomash

Quoted 24 lines
---
 drivers/scsi/aic94xx/aic94xx_hwi.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/aic94xx/aic94xx_hwi.c +3 -2
@@ -228,8 +228,10 @@ 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);
 		return -ENOMEM;
+	}
 
 	spin_lock_init(&seq->tc_index_lock);
 
--

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