Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3743784pxk; Tue, 29 Sep 2020 05:19:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTrwrxrmXCR6oEURhxb7zWKH5lTznKnPJRrI5vuFlvMxH00zxEKpY0Qij8Xuo+DyKZVFZk X-Received: by 2002:aa7:c2d6:: with SMTP id m22mr2891287edp.311.1601381955066; Tue, 29 Sep 2020 05:19:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601381955; cv=none; d=google.com; s=arc-20160816; b=c1le5hB6gPJnewgENKy5TxkP5vW7u5p240eZv+xkDt/GXO92oQLwcAbOteK6aU1ztH 1Bo6+Cd+yBSoPznNfoIHjTwNlKq5OlwznZ3joPxuY0WCQJWmdBmca1cccqvl8HKATFKl tceVr8NgZhDtcDDvHJV71cMKO6EcehDDuQTuOsIA1dZUjDoKxuqoec+ku/TX4Bpb3wGa eYceJFLr1kWIURFImvXxa7zRoeKVD7WyJUV3NOwEuBIkwM5Zig2MmVCtvS+DhD3Xq/gO Zh/o0rKJhF+gtCV9ExeYYYeLPy8FNFr4DL8VBmmzqoeXjY8mgBhiTQ4vcVExEon/9awh +DVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XD9yKlx8rBsSyjXdjdBchd24jrGpZ8Mn4+BLwZN51BI=; b=E7k+WJSQcT+CnJE4+WkK/uGqMCJIQ7e4LHbwUK37bRj9BqTL7kO0icrbHSxLXzzVQ4 d+D1nGFwvdfPI/k4Cmo22wPO67DSC1YwkcHDtH+KqHhYhcjq62kkpNtDidL6Uk78V+iL ya+MbuLo1AasICsB63tJrbHdbMZJ3BlUmIvUtHnUS9Y6klMYF3+a3I13m1ybfMAt+bNk JSzhlHPq8QhF2bUd+xPEqt9y8NwI4b6isymwFBpOtUCgkZ4ZKLFOM+kcfMgE4l6QWvLF lzex9B2QkyC8EN0rARkmiHhmaw9sGJW+uUc2WSvTxZYf7pOpMwrMECyAc7qIY9x7lcGD rykw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cvnSOtpJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g17si2714195ejr.649.2020.09.29.05.18.51; Tue, 29 Sep 2020 05:19:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cvnSOtpJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731651AbgI2MR4 (ORCPT + 99 others); Tue, 29 Sep 2020 08:17:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:53442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729320AbgI2Lgx (ORCPT ); Tue, 29 Sep 2020 07:36:53 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5534323E52; Tue, 29 Sep 2020 11:31:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379117; bh=ZnLj/QanGbny801H/qtAJkF9ao4X/iYTvxHzv8kHxjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cvnSOtpJHDVeIk+jR/ZkDhvn9qnrJA/2dcUL/LGo021Fz8OHzvwlY6BilXeblZ3Wy U+OxtAyYE0dur/rQ2nPdaIJ01EaOCWp3nTHscNnh/ph2HUVtEuzDGq5zd3/w3NLTwO DbKnnOFkU8GWnPbYSX5ds82j8FCOxuVyOOxQq3As= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sreekanth Reddy , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.4 003/388] scsi: mpt3sas: Free diag buffer without any status check Date: Tue, 29 Sep 2020 12:55:34 +0200 Message-Id: <20200929110010.645141512@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929110010.467764689@linuxfoundation.org> References: <20200929110010.467764689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sreekanth Reddy [ Upstream commit 764f472ba4a7a0c18107ebfbe1a9f1f5f5a1e411 ] Memory leak can happen when diag buffer is released but not unregistered (where buffer is deallocated) by the user. During module unload time driver is not deallocating the buffer if the buffer is in released state. Deallocate the diag buffer during module unload time without any diag buffer status checks. Link: https://lore.kernel.org/r/1568379890-18347-5-git-send-email-sreekanth.reddy@broadcom.com Signed-off-by: Sreekanth Reddy Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index d5a62fea8fe3e..bae7cf70ee177 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -3717,12 +3717,6 @@ mpt3sas_ctl_exit(ushort hbas_to_enumerate) for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) { if (!ioc->diag_buffer[i]) continue; - if (!(ioc->diag_buffer_status[i] & - MPT3_DIAG_BUFFER_IS_REGISTERED)) - continue; - if ((ioc->diag_buffer_status[i] & - MPT3_DIAG_BUFFER_IS_RELEASED)) - continue; dma_free_coherent(&ioc->pdev->dev, ioc->diag_buffer_sz[i], ioc->diag_buffer[i], -- 2.25.1