From patchwork Fri Nov 25 12:23:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Lambert X-Patchwork-Id: 9447427 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 848606071C for ; Fri, 25 Nov 2016 12:27:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 775EA280CF for ; Fri, 25 Nov 2016 12:27:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6965A28118; Fri, 25 Nov 2016 12:27:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0928D280CF for ; Fri, 25 Nov 2016 12:27:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753126AbcKYM1a (ORCPT ); Fri, 25 Nov 2016 07:27:30 -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 Received: by mail-lf0-f67.google.com with SMTP id o141so3276757lff.1; Fri, 25 Nov 2016 04:27:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:reply-to; bh=/ciMCXhSLTH1UNxu1S3ovHRxAgKYrSnIJOel+SnvQM8=; b=K0fK4CIgVOpWodNZYPOgO8h6WRfjatUR14kmbRFVr4R+pVHLHWRO59Y/neXXX2M01p qoTblkv/s9EQmoYq3/lRhfUJDvnsLqG+tGnSH0m3LXwUUTv+TmAq6OWiAJ4sER57Fl3Q xyirjTbbGPbcknaccCBQGAdb3HBGQeNxkDSxVW03VMcNnu7/MMnF2JgV/0Z/uzH86tHY fQOOM3eeHWE0mkb/xJTuIwZCLEIL+TH6Y6kuefHIQVR6f/Ye6JChhWpbvShUlZ5vhIcJ KA5/eDadPN0MxC5Ib1CaHkuGRaBNvOUe7TUlVTGcw9DzO65l8AUUeHz0Lc1tcOONQDBo +cfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/ciMCXhSLTH1UNxu1S3ovHRxAgKYrSnIJOel+SnvQM8=; b=VCEGTTmC6i7laZaUmGGURcM9rh/OElqV/fDRILzPkiyHfEObvx9qa4dlQwjhaTkLVN TVBsv5jmSciEjuC34d5FwsYXi0IaBrtFNa3j9fjrsHiQ6hE/tVe17B9wax4IRCQgs2ck wjEI5sAoYMK8eJDUdBRDoxDJsGEAiLP5xojQjloksN02iPDgm5S5BPqeD+vy9mIMpFl5 oh7MtK2oLuAmnafrQonP/qtDE5I3bRYT92DcFxhRWrzK4zDB6vWjoTXoLx43wCbOZciI NhL6lBrOk6uF+GE2Fve5dSOKkr2IeVr0PQXfNmCkI8J0pHA0Vt2s5SKLJZRocV6/+KzQ +O1g== X-Gm-Message-State: AKaTC00UcYpbtpim1/l97tAWwQi+7bu+rDI6ATVWU5GhXWnxpVJXA/8gVb2fcAPNag6gQg== X-Received: by 10.46.5.15 with SMTP id 15mr4147429ljf.64.1480076846823; Fri, 25 Nov 2016 04:27:26 -0800 (PST) Received: from localhost.localdomain (c83-248-71-130.bredband.comhem.se. [83.248.71.130]) by smtp.gmail.com with ESMTPSA id 10sm9280594ljo.36.2016.11.25.04.27.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Nov 2016 04:27:25 -0800 (PST) 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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Tomas Henzl --- v2: set the point to NULL after having freed it drivers/scsi/aic94xx/aic94xx_hwi.c | 5 ++++- 1 file changed, 4 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 --- 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);