]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
mlxsw: spectrum_acl: Fix mlxsw_sp_acl_tcam_group_add()'s error path
authorIdo Schimmel <idosch@nvidia.com>
Sun, 27 Sep 2020 06:42:11 +0000 (09:42 +0300)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 9 Nov 2020 13:48:23 +0000 (14:48 +0100)
BugLink: https://bugs.launchpad.net/bugs/1902110
[ Upstream commit 72865028582a678be1e05240e55d452e5c258eca ]

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Ian May <ian.may@canonical.com>
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c

index 295b27112d36759e3f3c423d966aa132cb742886..ec0d5a4a60a989d88c47acb810d3ab23be4491d9 100644 (file)
@@ -290,13 +290,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;
 }