Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758432AbcDHPm7 (ORCPT ); Fri, 8 Apr 2016 11:42:59 -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 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1063 Lines: 30 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)); -- 1.9.1