scsi: target: iscsi: Make sure the np under each tpg is unique
authorZouMingzhe <mingzhe.zou@easystack.cn>
Tue, 11 Jan 2022 05:47:42 +0000 (13:47 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Feb 2022 11:54:19 +0000 (12:54 +0100)
commit7dbda616fc64298cedfb5b6cd52049f8038234fb
treeb2a0ff418986b8c97f921ecb84c8167d4b8283ab
parent67baac10dd5ad1e9f50e8f2659984b3b0728d54e
scsi: target: iscsi: Make sure the np under each tpg is unique

[ 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 <mingzhe.zou@easystack.cn>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/target/iscsi/iscsi_target_tpg.c