Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp884823pxk; Thu, 17 Sep 2020 20:17:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgXuvCoVQ0U3BUgk71Xb/HEWoXtB1dm1mOg5GidGuyEb+S8XVME4zEhQEQNZkO/nCnXQqT X-Received: by 2002:a17:906:2354:: with SMTP id m20mr32952741eja.341.1600399059704; Thu, 17 Sep 2020 20:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600399059; cv=none; d=google.com; s=arc-20160816; b=0kP6kcaPuLK5WXs4CK+HNo3AgZtPBqWteC7mBQvvPXLLKtbGoBUv3GCN7yw2bmHi2u 5T1tdggkGiRWqUtQAKjX3Tl2wk/9Sqzyinqq9tp6L0xciyCgu2s8+rPtrYyH0+/rqLIf NJBshGqLlfmW9O1CBDJF0CpL6oLYJ3BEWxZBLtY15TZ257ZfgeUfbm2orapBGn3MIN07 1qsIdsBY0W9soWaTxMRZKLvL+l/pCENOsEMNCye337sbirpnG4gqWdSC/DbThEf/IbI6 UHklZf9S/WRTkQf4CNGkSEAvFB9Go4plGUvERWZ1VoYQo+0UVrJCaPdOGCqqMBBkE6XD o7bQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XD9yKlx8rBsSyjXdjdBchd24jrGpZ8Mn4+BLwZN51BI=; b=bYm27IJntVKXCbUcWJbR5FeWf1hLUAxrgiuheFcr3ITQrmF8I6ri/j5Ik1lWVHYnWr jAC1qngzf4nf8BAZXA/BzSIiawWutxSfUwZyDvi8gILPHKt4tWdU04W1WNaRTD0pjkSl cFJ2PJTcvSHlWwTKtRetLAVSd3AViJ95K0fe5aZws1sLa2DY2n0vD1EjT8wvDipClsQR FusZTTUxod/HhtU/fUF7N0DM2nx3/HsixJLxJnMZwmD1114L1QSl5lAmrwtc4HC33e5m 3M9BSewNH7RbkvY3GWQZaHQy0QBairCkrLOfCQgP8FLd+6PZUKy00Rys2mx0MsVfv6sL kjvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EhxEY5Jy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h6si1247035ejx.417.2020.09.17.20.17.16; Thu, 17 Sep 2020 20:17:39 -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=EhxEY5Jy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726316AbgIRCBU (ORCPT + 99 others); Thu, 17 Sep 2020 22:01:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:45384 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726219AbgIRCBR (ORCPT ); Thu, 17 Sep 2020 22:01:17 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A1F2F2137B; Fri, 18 Sep 2020 02:01:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394476; bh=ZnLj/QanGbny801H/qtAJkF9ao4X/iYTvxHzv8kHxjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EhxEY5JypYHKYOdzTGsjWzrKYStU80Zax6/hlpsJWIZWhgHwADJANx/CuIyfyCsWu q4D/ch7lUA7n7hWPIoK88WH1q4ZD61MAiiDVzpxbAk5AqFARzaCE9TRw1XEd4gVo3L MdXWswwitmzHEeCnR2eUHXhzZmbaYFwMEZjgQU0I= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sreekanth Reddy , "Martin K . Petersen" , Sasha Levin , MPT-FusionLinux.pdl@avagotech.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 004/330] scsi: mpt3sas: Free diag buffer without any status check Date: Thu, 17 Sep 2020 21:55:44 -0400 Message-Id: <20200918020110.2063155-4-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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