From patchwork Tue Apr 24 09:28:42 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: 10359093 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 6231160225 for ; Tue, 24 Apr 2018 09:29:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 568EA28D04 for ; Tue, 24 Apr 2018 09:29:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B58528D3B; Tue, 24 Apr 2018 09:29:48 +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 E87FB28D04 for ; Tue, 24 Apr 2018 09:29:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754018AbeDXJ3q (ORCPT ); Tue, 24 Apr 2018 05:29:46 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:46740 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753790AbeDXJ3j (ORCPT ); Tue, 24 Apr 2018 05:29:39 -0400 Received: by mail-qt0-f194.google.com with SMTP id h4-v6so21079499qtn.13 for ; Tue, 24 Apr 2018 02:29:39 -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=ZIZw4jgeGjRrbQWd/9T5BB2ef3F6rBvoruqu29kKEu77AFtNkcE/O66FTenHdfu4lN Fvuh0UyAPIkabO4xv6w9SWt7/Q7MKLsp8eiKZQ6rgUjD8sdu8He40HKlZxf2ex4lU+nd 0KPHlTU4ae5isQF01zoujYwLnL9RBW+RoaV6U= 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=L6ja4QYdk/htJAzkQj3KExnuHI3E3DyE6M3fYQYnvEqW1LS63mj5mEmSURjqdFpWKp cBYyNvjdYBHnfzve94NOK07RG8b3GdGsoKY8/DZ/uSNujAM+VbBBqQ276yHpr+kmyxiG jRXe3dPAJB40so6jRX5lVSlahXJEeOyHat8aFYLtZjjGABTsoJ4Y4t+kPjcBtwb+XnJL xwmAh1Jc/V2s5bcVBUl3t9qOGhtlNVyPbcSnwCMjATxzUyxPH+4xrTC5igRlWxiUkyqJ ZN7u8vMWM2SWRN1m5FwnpykKxP6EBaJcsdmSa/Uxsx3At27Kt2z0tmw9mJ1/uAlFq9Th jzvg== X-Gm-Message-State: ALQs6tBkc+baHjnqfg3l+CI7i3SNGmOO8kCoSzVURvKamuk/VHuA9vb4 MRHkiAUu3PDkerc5W6I48RxRYY7pa5c= X-Google-Smtp-Source: AIpwx4+/e7IJM9SK8O352YElFtorOt/q4K8vign2p3E5Yln86Qxg5zuN4vnWRZ0hCTvm1WQ+eNyaAQ== X-Received: by 2002:aed:2765:: with SMTP id n92-v6mr28111224qtd.215.1524562178738; Tue, 24 Apr 2018 02:29:38 -0700 (PDT) Received: from localhost.localdomain.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 96sm12615184qkx.71.2018.04.24.02.29.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 02:29:38 -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 v3 13/14] mpt3sas: fix possible memory leak. Date: Tue, 24 Apr 2018 05:28:42 -0400 Message-Id: <1524562123-33229-14-git-send-email-chaitra.basappa@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1524562123-33229-1-git-send-email-chaitra.basappa@broadcom.com> References: <1524562123-33229-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(); }