From: Shresth Prasad <shresthprasad7@gmail.com>
To: robh@kernel.org, saravanak@google.com
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
javier.carrasco.cruz@gmail.com, skhan@linuxfoundation.org,
Shresth Prasad <shresthprasad7@gmail.com>,
Julia Lawall <julia.lawall@inria.fr>
Subject: [PATCH][next] of: property: Use scope based cleanup on port_node
Date: Sun, 28 Apr 2024 17:22:27 +0530 [thread overview]
Message-ID: <20240428115226.41345-2-shresthprasad7@gmail.com> (raw)
Use __free cleanup handler which ensures that the resource is freed when
it goes out of scope, thus removing the need to manually clean it up
using of_node_put.
Suggested-by: Julia Lawall <julia.lawall@inria.fr>
Signed-off-by: Shresth Prasad <shresthprasad7@gmail.com>
---
Rob Herring <robh@kernel.org> sent a patch fixing similar cases in
property.c but seems to have missed this one. Please let me know if this
is mistake, or if it was left unchanged for a reason.
drivers/of/property.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/of/property.c b/drivers/of/property.c
index 6d5ae58a7ac9..abc8613b471f 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -576,7 +576,8 @@ EXPORT_SYMBOL_GPL(of_prop_next_string);
int of_graph_parse_endpoint(const struct device_node *node,
struct of_endpoint *endpoint)
{
- struct device_node *port_node = of_get_parent(node);
+ struct device_node *port_node __free(device_node) =
+ of_get_parent(node);
WARN_ONCE(!port_node, "%s(): endpoint %pOF has no parent node\n",
__func__, node);
@@ -591,8 +592,6 @@ int of_graph_parse_endpoint(const struct device_node *node,
of_property_read_u32(port_node, "reg", &endpoint->port);
of_property_read_u32(node, "reg", &endpoint->id);
- of_node_put(port_node);
-
return 0;
}
EXPORT_SYMBOL(of_graph_parse_endpoint);
--
2.44.0
next reply other threads:[~2024-04-28 11:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-28 11:52 Shresth Prasad [this message]
2024-04-29 16:27 ` [PATCH][next] of: property: Use scope based cleanup on port_node Rob Herring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240428115226.41345-2-shresthprasad7@gmail.com \
--to=shresthprasad7@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=javier.carrasco.cruz@gmail.com \
--cc=julia.lawall@inria.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=saravanak@google.com \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).