From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D72DC433EF for ; Mon, 14 Feb 2022 09:31:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243541AbiBNJbT (ORCPT ); Mon, 14 Feb 2022 04:31:19 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243633AbiBNJbA (ORCPT ); Mon, 14 Feb 2022 04:31:00 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EACCF655C3; Mon, 14 Feb 2022 01:30:03 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8E636B80DC9; Mon, 14 Feb 2022 09:30:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A709DC340E9; Mon, 14 Feb 2022 09:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644831002; bh=sRCeHRUcEVzofXBICCRpX95loDW+YUQQzIAVjutA1HM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2BnO9T2jHrMgxj7ZdpnQTMm1f4gqySWlEsxdeLIBMqq5RM5BCNLt0TBFlBkJD1QS7 VzUz+T7p1ClEy6y3LuD2Ir70lMHmjAHwRNrrKI6K0fkQ4QzDSO6pD5TcoRje8W4+il 4ox2Mhhl41I8tgTXcRsfwgIYEUEB671PPrKnoHcQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, ZouMingzhe , Mike Christie , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.14 13/44] scsi: target: iscsi: Make sure the np under each tpg is unique Date: Mon, 14 Feb 2022 10:25:36 +0100 Message-Id: <20220214092448.341657325@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214092447.897544753@linuxfoundation.org> References: <20220214092447.897544753@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: ZouMingzhe [ Upstream commit a861790afaa8b6369eee8a88c5d5d73f5799c0c6 ] iscsit_tpg_check_network_portal() has nested for_each loops and is supposed to return true when a match is found. However, the tpg loop will still continue after existing the tpg_np loop. If this tpg_np is not the last the match value will be changed. Break the outer loop after finding a match and make sure the np under each tpg is unique. Link: https://lore.kernel.org/r/20220111054742.19582-1-mingzhe.zou@easystack.cn Signed-off-by: ZouMingzhe Reviewed-by: Mike Christie Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/target/iscsi/iscsi_target_tpg.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c index 16e7516052a44..2b78843091a2e 100644 --- a/drivers/target/iscsi/iscsi_target_tpg.c +++ b/drivers/target/iscsi/iscsi_target_tpg.c @@ -448,6 +448,9 @@ static bool iscsit_tpg_check_network_portal( break; } spin_unlock(&tpg->tpg_np_lock); + + if (match) + break; } spin_unlock(&tiqn->tiqn_tpg_lock); -- 2.34.1