diff mbox

scsi: aic94xx: Add a missing call to kfree

Message ID 20161119174038.20083-1-lambert.quentin@gmail.com (mailing list archive)
State Changes Requested, archived
Headers show

Commit Message

Quentin Lambert Nov. 19, 2016, 5:40 p.m. UTC
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.

Signed-off-by: Quentin Lambert <lambert.quentin@gmail.com>

---
 drivers/scsi/aic94xx/aic94xx_hwi.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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

Comments

Tomas Henzl Nov. 22, 2016, 3:51 p.m. UTC | #1
On 19.11.2016 18:40, Quentin Lambert wrote:
> 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

> Signed-off-by: Quentin Lambert <lambert.quentin@gmail.com>
>
> ---
>  drivers/scsi/aic94xx/aic94xx_hwi.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> --- a/drivers/scsi/aic94xx/aic94xx_hwi.c
> +++ b/drivers/scsi/aic94xx/aic94xx_hwi.c
> @@ -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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

Patch

--- a/drivers/scsi/aic94xx/aic94xx_hwi.c
+++ b/drivers/scsi/aic94xx/aic94xx_hwi.c
@@ -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);