diff mbox series

[net] mlxsw: spectrum_acl: Fix mlxsw_sp_acl_tcam_group_add()'s error path

Message ID 20200927064211.1412383-1-idosch@idosch.org
State New
Headers show
Series [net] mlxsw: spectrum_acl: Fix mlxsw_sp_acl_tcam_group_add()'s error path | expand

Commit Message

Ido Schimmel Sept. 27, 2020, 6:42 a.m. UTC
From: Ido Schimmel <idosch@nvidia.com>

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")
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

David Miller Sept. 27, 2020, 8:24 p.m. UTC | #1
From: Ido Schimmel <idosch@idosch.org>
Date: Sun, 27 Sep 2020 09:42:11 +0300

> From: Ido Schimmel <idosch@nvidia.com>
> 
> 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")
> Signed-off-by: Ido Schimmel <idosch@nvidia.com>
> Reviewed-by: Jiri Pirko <jiri@nvidia.com>

Applied and queued up for -stable.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c
index 5c020403342f..7cccc41dd69c 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c
@@ -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;
 }