From patchwork Mon Apr 9 10:05:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitra P B X-Patchwork-Id: 10330963 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 7F2556037F for ; Mon, 9 Apr 2018 10:05:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7934427816 for ; Mon, 9 Apr 2018 10:05:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AE0428ADD; Mon, 9 Apr 2018 10:05:57 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 0437327816 for ; Mon, 9 Apr 2018 10:05:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751875AbeDIKF4 (ORCPT ); Mon, 9 Apr 2018 06:05:56 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:38295 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751862AbeDIKFz (ORCPT ); Mon, 9 Apr 2018 06:05:55 -0400 Received: by mail-qk0-f196.google.com with SMTP id 132so8587771qkd.5 for ; Mon, 09 Apr 2018 03:05:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OquLxQUDJXx/bYqJ/DH1zPOu3mxIkGy2okfgc01FqtQ=; b=TNNAfX++RiKDgiERnPkwNAnqV9Mhp+U1dzemgM+4CH+MYbDXqB4UZx/520mt8gT3sM IE6WCWi4ILvVaIcmFXX30HqJVyFSs4UZGKrvXMlFHGSNHtMr9dtslN7Mz+LF5BdtaUeT RIUbZWNWSB825Rx5h222g3mCNEtF1wTe2J8Ic= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OquLxQUDJXx/bYqJ/DH1zPOu3mxIkGy2okfgc01FqtQ=; b=ToU2L1pJiC2xSrioAOwzQQw76I0daFGQOJKfvsYk50i0Jvg8NRphrSVpDfYInMR4bT 6hIAyFNsPGwV2/v7jZTa7MGEPp1sXmnRWZlqOcvsRJ9UbpdJdk/52gKK7FhVzmGISMU2 UrM5LCC32+F7YZoIwqPq1BN1WVpKFN9H0T2IYyFQbhsg2EQeioVZEyi8wLPYqCu5h3Bu wI1l3c0pTqm97pgGCbi2JATvwnM3RX5A+eYvXZwNi8p7a6U/U2z0oy44py3l6r6uqaw2 eQnCqPStgmesjLIb4ySF23YkR4prySmlMYB3aDji8aSQF9yfGAyf37XsGPZ29LIx4I8B zAwQ== X-Gm-Message-State: ALQs6tCbJNTdiTMys/Z5PX1yhln0kjhOZurtGuwnzRig90yLsZ29kffZ cUXUM+K7U+SY87elXicuOehWB5W2Jp4= X-Google-Smtp-Source: AIpwx49EQwM/CcW+W0+owlmZKSDK9ubrvrZiPe4CyVyiGPs6TO5aMZ5QFARMF+KT6mW2uKESALOImQ== X-Received: by 10.55.4.132 with SMTP id 126mr48821069qke.277.1523268354822; Mon, 09 Apr 2018 03:05:54 -0700 (PDT) Received: from localhost.localdomain.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id l52sm13856884qtc.45.2018.04.09.03.05.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Apr 2018 03:05:54 -0700 (PDT) From: Chaitra P B To: linux-scsi@vger.kernel.org Cc: Sathya.Prakash@broadcom.com, sreekanth.reddy@broadcom.com, suganath-prabu.subramani@broadcom.com, Chaitra P B Subject: [PATCH v2 13/14] mpt3sas: fix possible memory leak. Date: Mon, 9 Apr 2018 06:05:00 -0400 Message-Id: <1523268301-14453-14-git-send-email-chaitra.basappa@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1523268301-14453-1-git-send-email-chaitra.basappa@broadcom.com> References: <1523268301-14453-1-git-send-email-chaitra.basappa@broadcom.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 In ioctl exit path driver refers ioc_list to free memory associated with diag buffers and event_log pointer used to save events by driver. If ctl_exit() func is called after unregistering driver, then ioc_list will be empty and hence driver will not be able to free the allocated memory which in turn causes memory leak. So call ctl_exit() function before unregistering mpt3sas driver. Signed-off-by: Chaitra P B Signed-off-by: Suganath Prabu S --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 8ba72a2..8fc2922 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -11276,10 +11276,10 @@ _mpt3sas_exit(void) pr_info("mpt3sas version %s unloading\n", MPT3SAS_DRIVER_VERSION); - pci_unregister_driver(&mpt3sas_driver); - mpt3sas_ctl_exit(hbas_to_enumerate); + pci_unregister_driver(&mpt3sas_driver); + scsih_exit(); }