Return-Path: Received: from mail-by2nam01on0120.outbound.protection.outlook.com ([104.47.34.120]:3328 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S964939AbeCSQIZ (ORCPT ); Mon, 19 Mar 2018 12:08:25 -0400 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Varun Prakash , "Martin K . Petersen" , Sasha Levin Subject: [PATCH AUTOSEL for 4.4 051/167] scsi: csiostor: fix use after free in csio_hw_use_fwconfig() Date: Mon, 19 Mar 2018 16:06:24 +0000 Message-ID: <20180319160513.16384-51-alexander.levin@microsoft.com> References: <20180319160513.16384-1-alexander.levin@microsoft.com> In-Reply-To: <20180319160513.16384-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: Varun Prakash [ Upstream commit a351e40b6de550049423a26f7ded7b639e363d89 ] mbp pointer is passed to csio_hw_validate_caps() so call mempool_free() after calling csio_hw_validate_caps(). Signed-off-by: Varun Prakash Fixes: 541c571fa2fd ("csiostor:Use firmware version from cxgb4/t4fw_version= .h") Reviewed-by: Johannes Thumshirn Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/csiostor/csio_hw.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/csiostor/csio_hw.c b/drivers/scsi/csiostor/csio_h= w.c index 622bdabc8894..dab195f04da7 100644 --- a/drivers/scsi/csiostor/csio_hw.c +++ b/drivers/scsi/csiostor/csio_hw.c @@ -1769,7 +1769,6 @@ csio_hw_use_fwconfig(struct csio_hw *hw, int reset, u= 32 *fw_cfg_param) goto bye; } =20 - mempool_free(mbp, hw->mb_mempool); if (finicsum !=3D cfcsum) { csio_warn(hw, "Config File checksum mismatch: csum=3D%#x, computed=3D%#x\n", @@ -1780,6 +1779,10 @@ csio_hw_use_fwconfig(struct csio_hw *hw, int reset, = u32 *fw_cfg_param) rv =3D csio_hw_validate_caps(hw, mbp); if (rv !=3D 0) goto bye; + + mempool_free(mbp, hw->mb_mempool); + mbp =3D NULL; + /* * Note that we're operating with parameters * not supplied by the driver, rather than from hard-wired --=20 2.14.1