Return-Path: Received: from mail-by2nam01on0117.outbound.protection.outlook.com ([104.47.34.117]:58464 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934546AbeCSP4j (ORCPT ); Mon, 19 Mar 2018 11:56:39 -0400 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Jason Yan , John Garry , chenqilin , chenxiang , "Martin K . Petersen" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 68/97] scsi: libsas: fix memory leak in sas_smp_get_phy_events() Date: Mon, 19 Mar 2018 15:55:59 +0000 Message-ID: <20180319155411.12348-68-alexander.levin@microsoft.com> References: <20180319155411.12348-1-alexander.levin@microsoft.com> In-Reply-To: <20180319155411.12348-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Jason Yan [ Upstream commit 4a491b1ab11ca0556d2fda1ff1301e862a2d44c4 ] We've got a memory leak with the following producer: while true; do cat /sys/class/sas_phy/phy-1:0:12/invalid_dword_count >/dev/null; done The buffer req is allocated and not freed after we return. Fix it. Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver") Signed-off-by: Jason Yan CC: John Garry CC: chenqilin CC: chenxiang Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/libsas/sas_expander.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_e= xpander.c index 324d8d8c62de..fc17b4a5217e 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -695,6 +695,7 @@ int sas_smp_get_phy_events(struct sas_phy *phy) phy->phy_reset_problem_count =3D scsi_to_u32(&resp[24]); =20 out: + kfree(req); kfree(resp); return res; =20 --=20 2.14.1