diff mbox series

target: make sure the np under each tpg is unique

Message ID 20220111054548.19479-1-mingzhe.zou@easystack.cn
State New
Headers show
Series target: make sure the np under each tpg is unique | expand

Commit Message

Zou Mingzhe Jan. 11, 2022, 5:45 a.m. UTC
From: ZouMingzhe <mingzhe.zou@easystack.cn>

iscsit_tpg_check_network_portal() has two-layer for loop, and
should return true When a match is found. Then, the tpg loop
will still continue after break the tpg_np loop. If this tpg_np
is not the last, the match value will be changed.

This patch break all loops after finding a match, and make sure
the np under each tpg is unique.

Signed-off-by: ZouMingzhe <mingzhe.zou@easystack.cn>
---
 drivers/target/iscsi/iscsi_target_tpg.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Mike Christie Jan. 13, 2022, 1:20 a.m. UTC | #1
On 1/10/22 11:45 PM, mingzhe.zou@easystack.cn wrote:
> From: ZouMingzhe <mingzhe.zou@easystack.cn>
> 
> iscsit_tpg_check_network_portal() has two-layer for loop, and
> should return true When a match is found. Then, the tpg loop
> will still continue after break the tpg_np loop. If this tpg_np
> is not the last, the match value will be changed.
> 
> This patch break all loops after finding a match, and make sure
> the np under each tpg is unique.
> 
> Signed-off-by: ZouMingzhe <mingzhe.zou@easystack.cn>
> ---
>  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 8075f60fd02c..2d5cf1714ae0 100644
> --- a/drivers/target/iscsi/iscsi_target_tpg.c
> +++ b/drivers/target/iscsi/iscsi_target_tpg.c
> @@ -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);
>  

Reviewed-by: Mike Christie <michael.christie@oracle.com>
diff mbox series

Patch

diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c
index 8075f60fd02c..2d5cf1714ae0 100644
--- a/drivers/target/iscsi/iscsi_target_tpg.c
+++ b/drivers/target/iscsi/iscsi_target_tpg.c
@@ -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);