]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cdx: Unlock on error path in rescan_store()
authorDan Carpenter <dan.carpenter@linaro.org>
Tue, 2 Jan 2024 13:11:16 +0000 (16:11 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 23:45:25 +0000 (15:45 -0800)
[ Upstream commit 1960932eef9183e2dab662fe75126f7fa46e0e6d ]

We added locking to this function but these two error paths were
accidentally overlooked.

Fixes: f0af81683466 ("cdx: Introduce lock to protect controller ops")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
Link: https://lore.kernel.org/r/a7994b47-6f78-4e2c-a30a-ee5995d428ec@moroto.mountain
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/cdx/cdx.c

index 40035dd2e2997303468740527f0dcc758fb28031..7c1c1f82a3263bc9add790d45f29a1928b9f882a 100644 (file)
@@ -575,7 +575,8 @@ static ssize_t rescan_store(const struct bus_type *bus,
                pd = of_find_device_by_node(np);
                if (!pd) {
                        of_node_put(np);
-                       return -EINVAL;
+                       count = -EINVAL;
+                       goto unlock;
                }
 
                cdx = platform_get_drvdata(pd);
@@ -585,6 +586,7 @@ static ssize_t rescan_store(const struct bus_type *bus,
                put_device(&pd->dev);
        }
 
+unlock:
        mutex_unlock(&cdx_controller_lock);
 
        return count;