* [PATCH] PM / devfreq: event: Call of_node_put() only once in devfreq_event_get_edev_by_phandle()
@ 2024-10-03 9:15 Markus Elfring
2024-12-08 12:36 ` Chanwoo Choi
0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2024-10-03 9:15 UTC (permalink / raw)
To: linux-pm, Chanwoo Choi, Kyungmin Park, MyungJoo Ham; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 3 Oct 2024 11:01:30 +0200
An of_node_put(node) call was immediately used after a null pointer check
for the local variable “edev” at the end of this function implementation.
Thus call such a function only once instead directly before the check.
This issue was transformed by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/devfreq/devfreq-event.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/devfreq/devfreq-event.c b/drivers/devfreq/devfreq-event.c
index 3ebac2496679..70219099c604 100644
--- a/drivers/devfreq/devfreq-event.c
+++ b/drivers/devfreq/devfreq-event.c
@@ -244,13 +244,9 @@ struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(struct device *dev,
edev = NULL;
out:
mutex_unlock(&devfreq_event_list_lock);
-
- if (!edev) {
- of_node_put(node);
- return ERR_PTR(-ENODEV);
- }
-
of_node_put(node);
+ if (!edev)
+ return ERR_PTR(-ENODEV);
return edev;
}
--
2.46.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] PM / devfreq: event: Call of_node_put() only once in devfreq_event_get_edev_by_phandle()
2024-10-03 9:15 [PATCH] PM / devfreq: event: Call of_node_put() only once in devfreq_event_get_edev_by_phandle() Markus Elfring
@ 2024-12-08 12:36 ` Chanwoo Choi
0 siblings, 0 replies; 2+ messages in thread
From: Chanwoo Choi @ 2024-12-08 12:36 UTC (permalink / raw)
To: Markus Elfring
Cc: linux-pm, Chanwoo Choi, Kyungmin Park, MyungJoo Ham, LKML,
kernel-janitors
Hi,
Applied it. Thanks.
On Thu, Oct 3, 2024 at 6:15 PM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 3 Oct 2024 11:01:30 +0200
>
> An of_node_put(node) call was immediately used after a null pointer check
> for the local variable “edev” at the end of this function implementation.
> Thus call such a function only once instead directly before the check.
>
> This issue was transformed by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/devfreq/devfreq-event.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/devfreq/devfreq-event.c b/drivers/devfreq/devfreq-event.c
> index 3ebac2496679..70219099c604 100644
> --- a/drivers/devfreq/devfreq-event.c
> +++ b/drivers/devfreq/devfreq-event.c
> @@ -244,13 +244,9 @@ struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(struct device *dev,
> edev = NULL;
> out:
> mutex_unlock(&devfreq_event_list_lock);
> -
> - if (!edev) {
> - of_node_put(node);
> - return ERR_PTR(-ENODEV);
> - }
> -
> of_node_put(node);
> + if (!edev)
> + return ERR_PTR(-ENODEV);
>
> return edev;
> }
> --
> 2.46.1
>
>
--
Best Regards,
Chanwoo Choi
Samsung Electronics
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-08 12:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-03 9:15 [PATCH] PM / devfreq: event: Call of_node_put() only once in devfreq_event_get_edev_by_phandle() Markus Elfring
2024-12-08 12:36 ` Chanwoo Choi
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®