Skip to contentSkip to conversation

mlxsw: spectrum_acl: Fix mlxsw_sp_acl_tcam_group_add()'s error path

PATCH In review Ido Schimmel 2 participants 2 messages Sep 27, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mlxsw: spectrum_acl: Fix mlxsw_sp_acl_tcam_group_add()'s error path

From: Ido Schimmel <[email protected]>

If mlxsw_sp_acl_tcam_group_id_get() fails, the mutex initialized earlier is not destroyed.

Fix this by initializing the mutex after calling the function. This is symmetric to mlxsw_sp_acl_tcam_group_del().

Fixes 5ec2ee28d27b ("mlxsw: spectrum_acl: Introduce a mutex to guard region list updates")
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c +2 -1
index 5c020403342f..7cccc41dd69c 100644
@@ -292,13 +292,14 @@ mlxsw_sp_acl_tcam_group_add(struct mlxsw_sp_acl_tcam *tcam,
 	int err;
 
 	group->tcam = tcam;
-	mutex_init(&group->lock);
 	INIT_LIST_HEAD(&group->region_list);
 
 	err = mlxsw_sp_acl_tcam_group_id_get(tcam, &group->id);
 	if (err)
 		return err;
 
+	mutex_init(&group->lock);
+
 	return 0;
 }
 
Signature · 1 line
2.26.2
maintainer
#1 lore raw

From: Ido Schimmel <[email protected]>
Date: Sun, 27 Sep 2020 09:42:11 +0300

Quoted 11 lines

From: Ido Schimmel <[email protected]>

If mlxsw_sp_acl_tcam_group_id_get() fails, the mutex initialized earlier is not destroyed.

Fix this by initializing the mutex after calling the function. This is symmetric to mlxsw_sp_acl_tcam_group_del().

Fixes 5ec2ee28d27b ("mlxsw: spectrum_acl: Introduce a mutex to guard region list updates")

Applied and queued up for -stable.