From patchwork Fri Mar 30 09:37:23 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: 10317467 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 8872560212 for ; Fri, 30 Mar 2018 09:39:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7759C2A55F for ; Fri, 30 Mar 2018 09:39:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 699152A574; Fri, 30 Mar 2018 09:39: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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 022DC2A55F for ; Fri, 30 Mar 2018 09:39:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752344AbeC3Jjm (ORCPT ); Fri, 30 Mar 2018 05:39:42 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:41395 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751709AbeC3Jjj (ORCPT ); Fri, 30 Mar 2018 05:39:39 -0400 Received: by mail-qk0-f195.google.com with SMTP id s78so8637745qkl.8 for ; Fri, 30 Mar 2018 02:39: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=KundUWSCJRErwnY3BkePSdGGD/1PiOI9i5UHn8ADe1I=; b=UzoBtULXa7ZcNovYB8vRLKAt3/Ln7dzTtEddcpj83LtBNE5WTA3PdXdH5dPjUZ1qV4 BsPk9GThtxiUR5aAzgIZWwx8Oj9qOUBRoVDaCt1Zem0SoMCCpqEXjcnX9e+KuIXjZa7t b+xWfjG3cWGHWg98Fe/6sIskGzIw0azfumaes= 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=KundUWSCJRErwnY3BkePSdGGD/1PiOI9i5UHn8ADe1I=; b=CyKrv1ijSTj71YLguDGgXFS+FBIkXmqYIVcSnIb1W1LVoZsE+ycAZMtWuQbHTUQWY1 1nhi8M0SFTyHO7m7Zb7Bz0Rpb76rq1j+tO9ut3ku3vcTwdLi4Zb1aoeBnCTPlILvtrDZ 2kc5hvdM2YP1sZDj+M+VYyAZGP8kEWKQDLxI0H/HKm7Z4+HA7INOCTSy9CroFPZBihVQ zcaN+o+MsiuzISH0V1lrbjLLRS9VfZoc+nDtZTOZGQoy6OtD1Zq0q2X/z/nyppebyds+ nUhzGdDxA2cCie9aU+E5URpDuts9Sii4tcUJWt3YQMT4/dQaRr4phbK7u8cgevkNZiTw rEQA== X-Gm-Message-State: AElRT7HzFczL+V+HV/gH7x/WaxOVRpLPm6UFxUhvTSYEpjVYkxfWAGBA 6sbYjhDIxJkS9hCxvLcjSogfuLJG X-Google-Smtp-Source: AIpwx4+Tgk//wiX2bq8LeXWk1SHHh2WL/V/hqnCPtFo4pnJ8OQH2XNDqIodpYvsSTOPoCksODY3ogQ== X-Received: by 10.55.146.1 with SMTP id u1mr16161733qkd.327.1522402778782; Fri, 30 Mar 2018 02:39:38 -0700 (PDT) Received: from dhcp-10-122-86-193.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id n4sm1125526qkf.29.2018.03.30.02.39.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Mar 2018 02:39:38 -0700 (PDT) From: Chaitra P B To: linux-scsi@vger.kernel.org, stable@vger.kernel.org Cc: suganath-prabu.subramani@broadcom.com, Sathya.Prakash@broadcom.com, sreekanth.reddy@broadcom.com, Chaitra P B Subject: [PATCH 14/15] mpt3sas: fix possible memory leak. Date: Fri, 30 Mar 2018 15:07:23 +0530 Message-Id: <1522402644-3016-15-git-send-email-chaitra.basappa@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1522402644-3016-1-git-send-email-chaitra.basappa@broadcom.com> References: <1522402644-3016-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 f5344cc..562b13d 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -11286,10 +11286,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(); }