Return-Path: Received: from mail-co1nam03on0122.outbound.protection.outlook.com ([104.47.40.122]:54448 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934837AbeCSQAX (ORCPT ); Mon, 19 Mar 2018 12:00:23 -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.9 078/281] scsi: csiostor: fix use after free in csio_hw_use_fwconfig() Date: Mon, 19 Mar 2018 15:59:20 +0000 Message-ID: <20180319155742.13731-78-alexander.levin@microsoft.com> References: <20180319155742.13731-1-alexander.levin@microsoft.com> In-Reply-To: <20180319155742.13731-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