lkml.org 
[lkml]   [2023]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] cdx: Unlock on error path in rescan_store()
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>
---
drivers/cdx/cdx.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/cdx/cdx.c b/drivers/cdx/cdx.c
index d84d153078d7..f4f9f0c88c09 100644
--- a/drivers/cdx/cdx.c
+++ b/drivers/cdx/cdx.c
@@ -572,12 +572,16 @@ static ssize_t rescan_store(const struct bus_type *bus,

/* Rescan all the devices */
for_each_compatible_node(np, NULL, compat_node_name) {
- if (!np)
- return -EINVAL;
+ if (!np) {
+ count = -EINVAL;
+ goto unlock;
+ }

pd = of_find_device_by_node(np);
- if (!pd)
- return -EINVAL;
+ if (!pd) {
+ count = -EINVAL;
+ goto unlock;
+ }

cdx = platform_get_drvdata(pd);
if (cdx && cdx->controller_registered && cdx->ops->scan)
@@ -585,7 +589,7 @@ static ssize_t rescan_store(const struct bus_type *bus,

put_device(&pd->dev);
}
-
+unlock:
mutex_unlock(&cdx_controller_lock);

return count;
--
2.42.0
\
 
 \ /
  Last update: 2023-12-12 10:21    [W:0.048 / U:2.716 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site