From patchwork Fri Apr 8 15:42:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 8784231 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A68519F36E for ; Fri, 8 Apr 2016 15:43:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D2F7B2017D for ; Fri, 8 Apr 2016 15:43:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F13CE20148 for ; Fri, 8 Apr 2016 15:43:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755464AbcDHPm6 (ORCPT ); Fri, 8 Apr 2016 11:42:58 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:36809 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752821AbcDHPm5 (ORCPT ); Fri, 8 Apr 2016 11:42:57 -0400 Received: by mail-pa0-f49.google.com with SMTP id bx7so60662055pad.3; Fri, 08 Apr 2016 08:42:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=gnI2blXwVIl7BLoRPEzURIUja4zD8A3HTqAGxEBE0+0=; b=cAHUUUed6UR0vTYADpo9UjdMSdd4Fa+mjU0j+hPz1pDIoLLHIZoGyMgdYMNWB28VYG 4/Rb9YUedZnznSpahEeu5/yPVJ1cNcve1n1/RMLwgKSm3VkZw7asllEBR/S61eMWEfis UBtX1jv5eUHalvpER8MFbgzXQJLONiPZoP8edLDY8zmE9vf2OqUvkb3QduwychhblgPc YA6GScSEPBqGtJX9QedbjWylR+wtGfQeqiHD75UWBF7wDcPCnoTx9VE67yhF2s9YG4Kn aQoS1QqLKO18iXal1/DDqQOBHGmfF8Wg3PTIOhcTgjYvs3Yl+0SwAsu06eyRznEkzotA 4BHg== 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; bh=gnI2blXwVIl7BLoRPEzURIUja4zD8A3HTqAGxEBE0+0=; b=gDdV628wN7Qd6hJ3kK53xkheGlB/XxHGABlDbzgi9sEa6c8j9UrY1LFm0tJZ2Rd5Pu 0UDHU8v6Dg64G4C5DhlqfyQOHXNIJV3htlTg+AbcpdupqlGOJY0qeDJP8wLfd8POIMfD vLfpBzMS+QR3ZcDEt0XpD7v2x71crUR+PFhGMcppEpWAxPQkaPwUlzDjGBcyWzNajsPX Zzx0yadxZhvZ5/bFApt7RlI/pOwv0qLpWOEbzM+xOfeyV+N3hxZKAwfImkiMk3NP2vWB SyKcEtbDfJqEhM4z5iuGXzowhL2E+rfLnR4MWG/bqde77Q3/FJG2iQH09Ya2yMGpvcGt bV+Q== X-Gm-Message-State: AD7BkJKOePi3GS4ma6+BBnTPdc3Sa9qo2ZMYEtS1g4aVP7XdhdpCTef1+tfn32zuCDEaBQ== X-Received: by 10.66.120.46 with SMTP id kz14mr13604090pab.61.1460130176850; Fri, 08 Apr 2016 08:42:56 -0700 (PDT) Received: from localhost.localdomain ([103.24.124.194]) by smtp.gmail.com with ESMTPSA id q72sm19582070pfa.70.2016.04.08.08.42.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Apr 2016 08:42:55 -0700 (PDT) From: Sudip Mukherjee To: Sathya Prakash , Chaitra P B , Suganath Prabu Subramani , "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-kernel@vger.kernel.org, MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, Sudip Mukherjee Subject: [PATCH] mpt3sas: fix possible NULL dereference Date: Fri, 8 Apr 2016 21:12:42 +0530 Message-Id: <1460130162-30011-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We are dereferencing ioc->sense_dma_pool in pci_pool_free() and after that we are checking if it is NULL, before calling pci_pool_destroy(). Lets check if it is NULL before calling both pci_pool_free() and pci_pool_destroy(). Signed-off-by: Sudip Mukherjee --- drivers/scsi/mpt3sas/mpt3sas_base.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 8c44b9c..778c2ec 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -3087,9 +3087,11 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc) } if (ioc->sense) { - pci_pool_free(ioc->sense_dma_pool, ioc->sense, ioc->sense_dma); - if (ioc->sense_dma_pool) + if (ioc->sense_dma_pool) { + pci_pool_free(ioc->sense_dma_pool, ioc->sense, + ioc->sense_dma); pci_pool_destroy(ioc->sense_dma_pool); + } dexitprintk(ioc, pr_info(MPT3SAS_FMT "sense_pool(0x%p): free\n", ioc->name, ioc->sense));