mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] extcon: realtek: Use scope-based resource management in extcon_rtk_type_c_init()
@ 2024-06-04 20:06 Markus Elfring
  2024-06-04 21:11 ` Andy Shevchenko
  2024-06-29  9:44 ` [PATCH v2] extcon: realtek: Prevent resource leak " Markus Elfring
  0 siblings, 2 replies; 3+ messages in thread
From: Markus Elfring @ 2024-06-04 20:06 UTC (permalink / raw)
  To: kernel-janitors, Chanwoo Choi, MyungJoo Ham, Stanley Chang
  Cc: LKML, Andy Shevchenko

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Jun 2024 21:55:08 +0200

Scope-based resource management became supported also for another
programming interface by contributions of Jonathan Cameron on 2024-02-17.
See also the commit 59ed5e2d505bf5f9b4af64d0021cd0c96aec1f7c ("device
property: Add cleanup.h based fwnode_handle_put() scope based cleanup.").

* Thus use the attribute “__free(fwnode_handle)”.

* Reduce the scope for the local variable “fwnode”.

Fixes: 8a590d7371f0 ("extcon: add Realtek DHC RTD SoC Type-C driver")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/extcon/extcon-rtk-type-c.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/extcon/extcon-rtk-type-c.c b/drivers/extcon/extcon-rtk-type-c.c
index 19a01e663733..8a4b074fd745 100644
--- a/drivers/extcon/extcon-rtk-type-c.c
+++ b/drivers/extcon/extcon-rtk-type-c.c
@@ -18,6 +18,7 @@
 #include <linux/syscalls.h>
 #include <linux/suspend.h>
 #include <linux/debugfs.h>
+#include <linux/property.h>
 #include <linux/extcon.h>
 #include <linux/extcon-provider.h>
 #include <linux/sys_soc.h>
@@ -1237,7 +1238,6 @@ static int extcon_rtk_type_c_init(struct type_c_data *type_c)

 	if (!type_c->port) {
 		struct typec_capability typec_cap = { };
-		struct fwnode_handle *fwnode;
 		const char *buf;
 		int ret;

@@ -1246,7 +1246,8 @@ static int extcon_rtk_type_c_init(struct type_c_data *type_c)
 		typec_cap.driver_data = type_c;
 		typec_cap.ops = &type_c_port_ops;

-		fwnode = device_get_named_child_node(dev, "connector");
+		struct fwnode_handle *fwnode __free(fwnode_handle)
+					     = device_get_named_child_node(dev, "connector");
 		if (!fwnode)
 			return -EINVAL;

--
2.45.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-29  9:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-04 20:06 [PATCH] extcon: realtek: Use scope-based resource management in extcon_rtk_type_c_init() Markus Elfring
2024-06-04 21:11 ` Andy Shevchenko
2024-06-29  9:44 ` [PATCH v2] extcon: realtek: Prevent resource leak " Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®