[v2,2/2] cdx: Unlock on error path in rescan_store()

Message ID a7994b47-6f78-4e2c-a30a-ee5995d428ec@moroto.mountain
State New
Headers
Series [v2,1/2] cdx: call of_node_put() on error path |

Commit Message

Dan Carpenter Jan. 2, 2024, 1:11 p.m. UTC
  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>
---
v2: I rebased this patch on top of the other bugfix that Christophe
    JAILLET pointed out.  It's easier for backporting to do it in this
    order.

 drivers/cdx/cdx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Gangurde, Abhijit Jan. 4, 2024, 9:06 a.m. UTC | #1
> 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>

Thanks,
Abhijit
  

Patch

diff --git a/drivers/cdx/cdx.c b/drivers/cdx/cdx.c
index 40035dd2e299..7c1c1f82a326 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;