Skip to contentSkip to conversation

platform/surface: aggregator: Add missing fwnode_handle_put()

PATCH In review Liang He 3 participants 3 messages Mar 22, 2023

Subsystems (3)
lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 platform/surface: aggregator: Add missing fwnode_handle_put()

In fwnode_for_each_child_node(), we should add fwnode_handle_put() when break out of the iteration fwnode_for_each_child_node() as it will automatically increase and decrease the refcounter.

Fixes fc622b3d36e6 ("platform/surface: Set up Surface Aggregator device registry")
---
 drivers/platform/surface/aggregator/bus.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/surface/aggregator/bus.c +3 -1
index de539938896e..b501a79f2a08 100644
@@ -485,8 +485,10 @@ int __ssam_register_clients(struct device *parent, struct ssam_controller *ctrl,
 		 * device, so ignore it and continue with the next one.
 		 */
 		status = ssam_add_client_device(parent, ctrl, child);
-		if (status && status != -ENODEV)
+		if (status && status != -ENODEV) {
+			fwnode_handle_put(child);
 			goto err;
+		}
 	}
 
 	return 0;
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Liang He

In fwnode_for_each_child_node(), we should add fwnode_handle_put() when break out of the iteration fwnode_for_each_child_node() as it will automatically increase and decrease the refcounter.

Fixes fc622b3d36e6 ("platform/surface: Set up Surface Aggregator device registry")
---
  drivers/platform/surface/aggregator/bus.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/surface/aggregator/bus.c +0 -0
index de539938896e..b501a79f2a08 100644
@@ -485,8 +485,10 @@ int __ssam_register_clients(struct device *parent, struct ssam_controller *ctrl,
  		 * device, so ignore it and continue with the next one.

drivers/platform/surface/aggregator/bus.c int __ssam_register_clients(struct device *parent, struct ssam_controller *ctrl, · line 494

Quoted 10 lines
drivers/platform/surface/aggregator/bus.c +3 -1
  		 */
  		status = ssam_add_client_device(parent, ctrl, child);
-		if (status && status != -ENODEV)
+		if (status && status != -ENODEV) {
+			fwnode_handle_put(child);
  			goto err;
+		}
  	}
 
  	return 0;

Thanks for spotting this.

#2 lore raw

Hi,

Quoted 30 lines · Maximilian Luz
Quoted 16 lines · Liang He

In fwnode_for_each_child_node(), we should add fwnode_handle_put() when break out of the iteration fwnode_for_each_child_node() as it will automatically increase and decrease the refcounter.

Fixes fc622b3d36e6 ("platform/surface: Set up Surface Aggregator device registry")

---
  drivers/platform/surface/aggregator/bus.c | 4 +++-

  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/surface/aggregator/bus.c +0 -0
index de539938896e..b501a79f2a08 100644

drivers/platform/surface/aggregator/bus.c int __ssam_register_clients(struct device *parent, struct ssam_controller *ctrl, · line 493

Quoted 10 lines
drivers/platform/surface/aggregator/bus.c +3 -1
@@ -485,8 +485,10 @@ int __ssam_register_clients(struct device *parent, struct ssam_controller *ctrl,
            * device, so ignore it and continue with the next one.
            */
           status = ssam_add_client_device(parent, ctrl, child);
-        if (status && status != -ENODEV)
+        if (status && status != -ENODEV) {
+            fwnode_handle_put(child);
               goto err;
+        }
       }
         return 0;

Thanks for spotting this.

Quoted 1 line

Thank you both for the patch / review, I've applied this patch to the pdx86/fixes branch now:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=fixes

I will include this patch in my next fixes pull-req to Linus for the current kernel development cycle.

Regards,

Hans