Skip to content

Commit

Permalink
scsi: target: iscsi: Make sure the np under each tpg is unique
Browse files Browse the repository at this point in the history
[ Upstream commit a861790 ]

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>
  • Loading branch information
zoumingzhe authored and gregkh committed Feb 16, 2022
1 parent 43ae0cc commit 4f786e8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/target/iscsi/iscsi_target_tpg.c
Expand Up @@ -443,6 +443,9 @@ static bool iscsit_tpg_check_network_portal(
break;
}
spin_unlock(&tpg->tpg_np_lock);

if (match)
break;
}
spin_unlock(&tiqn->tiqn_tpg_lock);

Expand Down

0 comments on commit 4f786e8

Please sign in to comment.