* [PATCH v2] hwmon: (gsc-hwmon) Add missing of_node_put()
@ 2022-06-16 11:40 Liang He
2022-06-17 21:17 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Liang He @ 2022-06-16 11:40 UTC (permalink / raw)
To: tharvey, rjones, jdelvare, linux; +Cc: windhl, linux-hwmon, linux-kernel
In gsc_hwmon_get_devtree_pdata(), of_find_compatible_node() will return
a node pointer with refcount incremented. We should use of_node_put() in
fail path or when it is not used anymore.
Signed-off-by: Liang He <windhl@126.com>
---
drivers/hwmon/gsc-hwmon.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/hwmon/gsc-hwmon.c b/drivers/hwmon/gsc-hwmon.c
index 1fe37418ff46..d64be48f1ef6 100644
--- a/drivers/hwmon/gsc-hwmon.c
+++ b/drivers/hwmon/gsc-hwmon.c
@@ -269,10 +269,13 @@ gsc_hwmon_get_devtree_pdata(struct device *dev)
/* fan controller base address */
fan = of_find_compatible_node(dev->parent->of_node, NULL, "gw,gsc-fan");
if (fan && of_property_read_u32(fan, "reg", &pdata->fan_base)) {
+ of_node_put(fan);
dev_err(dev, "fan node without base\n");
return ERR_PTR(-EINVAL);
}
+ of_node_put(fan);
+
/* allocate structures for channels and count instances of each type */
device_for_each_child_node(dev, child) {
if (fwnode_property_read_string(child, "label", &ch->name)) {
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] hwmon: (gsc-hwmon) Add missing of_node_put()
2022-06-16 11:40 [PATCH v2] hwmon: (gsc-hwmon) Add missing of_node_put() Liang He
@ 2022-06-17 21:17 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2022-06-17 21:17 UTC (permalink / raw)
To: Liang He; +Cc: tharvey, rjones, jdelvare, linux-hwmon, linux-kernel
On Thu, Jun 16, 2022 at 07:40:24PM +0800, Liang He wrote:
> In gsc_hwmon_get_devtree_pdata(), of_find_compatible_node() will return
> a node pointer with refcount incremented. We should use of_node_put() in
> fail path or when it is not used anymore.
>
> Signed-off-by: Liang He <windhl@126.com>
Applied.
Thanks,
Guenter
> ---
> drivers/hwmon/gsc-hwmon.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/hwmon/gsc-hwmon.c b/drivers/hwmon/gsc-hwmon.c
> index 1fe37418ff46..d64be48f1ef6 100644
> --- a/drivers/hwmon/gsc-hwmon.c
> +++ b/drivers/hwmon/gsc-hwmon.c
> @@ -269,10 +269,13 @@ gsc_hwmon_get_devtree_pdata(struct device *dev)
> /* fan controller base address */
> fan = of_find_compatible_node(dev->parent->of_node, NULL, "gw,gsc-fan");
> if (fan && of_property_read_u32(fan, "reg", &pdata->fan_base)) {
> + of_node_put(fan);
> dev_err(dev, "fan node without base\n");
> return ERR_PTR(-EINVAL);
> }
>
> + of_node_put(fan);
> +
> /* allocate structures for channels and count instances of each type */
> device_for_each_child_node(dev, child) {
> if (fwnode_property_read_string(child, "label", &ch->name)) {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-17 21:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-16 11:40 [PATCH v2] hwmon: (gsc-hwmon) Add missing of_node_put() Liang He
2022-06-17 21:17 ` Guenter Roeck
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).