From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-by2nam03on0106.outbound.protection.outlook.com ([104.47.42.106]:32336 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932574AbeARVG1 (ORCPT ); Thu, 18 Jan 2018 16:06:27 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: tangwenji , Nicholas Bellinger , Sasha Levin Subject: [added to the 4.1 stable tree] iscsi-target: fix memory leak in lio_target_tiqn_addtpg() Date: Thu, 18 Jan 2018 21:01:44 +0000 Message-ID: <20180118205908.3220-262-alexander.levin@microsoft.com> References: <20180118205908.3220-1-alexander.levin@microsoft.com> In-Reply-To: <20180118205908.3220-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: tangwenji This patch has been added to the stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 12d5a43b2dffb6cd28062b4e19024f7982393288 ] tpg must free when call core_tpg_register() return fail Signed-off-by: tangwenji Signed-off-by: Nicholas Bellinger Signed-off-by: Sasha Levin --- drivers/target/iscsi/iscsi_target_configfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/= iscsi/iscsi_target_configfs.c index f6169f722991..bc578d3d2178 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c @@ -1466,7 +1466,7 @@ static struct se_portal_group *lio_target_tiqn_addtpg= ( ret =3D core_tpg_register(&iscsi_ops, wwn, &tpg->tpg_se_tpg, tpg, TRANSPORT_TPG_TYPE_NORMAL); if (ret < 0) - return NULL; + goto free_out; =20 ret =3D iscsit_tpg_add_portal_group(tiqn, tpg); if (ret !=3D 0) @@ -1478,6 +1478,7 @@ static struct se_portal_group *lio_target_tiqn_addtpg= ( return &tpg->tpg_se_tpg; out: core_tpg_deregister(&tpg->tpg_se_tpg); +free_out: kfree(tpg); return NULL; } --=20 2.11.0