From 92c5466b44b8b9cc3092034561d20c067c2d6fc9 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 2 Jan 2024 16:11:16 +0300 Subject: [PATCH] cdx: Unlock on error path in rescan_store() [ 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 Acked-by: Abhijit Gangurde Link: https://lore.kernel.org/r/a7994b47-6f78-4e2c-a30a-ee5995d428ec@moroto.mountain Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/cdx/cdx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/cdx/cdx.c b/drivers/cdx/cdx.c index 40035dd2e2997..7c1c1f82a3263 100644 --- a/drivers/cdx/cdx.c +++ b/drivers/cdx/cdx.c @@ -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; -- 2.47.3