Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754036AbcKYM1g (ORCPT ); Fri, 25 Nov 2016 07:27:36 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:34231 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751294AbcKYM12 (ORCPT ); Fri, 25 Nov 2016 07:27:28 -0500 From: Quentin Lambert To: "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, thenzl@redhat.com Cc: Quentin Lambert Subject: [PATCH v2] scsi: aic94xx: Add a missing call to kfree Date: Fri, 25 Nov 2016 13:23:51 +0100 Message-Id: <20161125122351.8226-1-lambert.quentin@gmail.com> X-Mailer: git-send-email 2.10.2 Reply-To: <20161119174038.20083-1-lambert.quentin@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 965 Lines: 28 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. Signed-off-by: Quentin Lambert --- v2: set the point to NULL after having freed it drivers/scsi/aic94xx/aic94xx_hwi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/scsi/aic94xx/aic94xx_hwi.c +++ b/drivers/scsi/aic94xx/aic94xx_hwi.c @@ -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);