* [PATCH] firmware: arm_scmi: Avoid leak OF node on error
@ 2022-05-23 11:11 cgel.zte
2022-05-23 11:53 ` Johan Hovold
2022-05-23 13:27 ` Sudeep Holla
0 siblings, 2 replies; 3+ messages in thread
From: cgel.zte @ 2022-05-23 11:11 UTC (permalink / raw)
To: sudeep.holla
Cc: cristian.marussi, linux-arm-kernel, linux-kernel, Minghao Chi,
Zeal Robot
From: Minghao Chi <chi.minghao@zte.com.cn>
The OF node should be put before returning error in smc_chan_available(),
otherwise node's refcount will be leaked.
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
---
drivers/firmware/arm_scmi/smc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
index 745acfdd0b3d..43018be70edc 100644
--- a/drivers/firmware/arm_scmi/smc.c
+++ b/drivers/firmware/arm_scmi/smc.c
@@ -55,10 +55,10 @@ static irqreturn_t smc_msg_done_isr(int irq, void *data)
static bool smc_chan_available(struct device *dev, int idx)
{
struct device_node *np = of_parse_phandle(dev->of_node, "shmem", 0);
+ of_node_put(np);
if (!np)
return false;
- of_node_put(np);
return true;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] firmware: arm_scmi: Avoid leak OF node on error
2022-05-23 11:11 [PATCH] firmware: arm_scmi: Avoid leak OF node on error cgel.zte
@ 2022-05-23 11:53 ` Johan Hovold
2022-05-23 13:27 ` Sudeep Holla
1 sibling, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2022-05-23 11:53 UTC (permalink / raw)
To: cgel.zte
Cc: sudeep.holla, cristian.marussi, linux-arm-kernel, linux-kernel,
Minghao Chi, Zeal Robot
On Mon, May 23, 2022 at 11:11:16AM +0000, cgel.zte@gmail.com wrote:
> From: Minghao Chi <chi.minghao@zte.com.cn>
>
> The OF node should be put before returning error in smc_chan_available(),
> otherwise node's refcount will be leaked.
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
> ---
> drivers/firmware/arm_scmi/smc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
> index 745acfdd0b3d..43018be70edc 100644
> --- a/drivers/firmware/arm_scmi/smc.c
> +++ b/drivers/firmware/arm_scmi/smc.c
> @@ -55,10 +55,10 @@ static irqreturn_t smc_msg_done_isr(int irq, void *data)
> static bool smc_chan_available(struct device *dev, int idx)
> {
> struct device_node *np = of_parse_phandle(dev->of_node, "shmem", 0);
> + of_node_put(np);
> if (!np)
> return false;
>
> - of_node_put(np);
> return true;
> }
NAK
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] firmware: arm_scmi: Avoid leak OF node on error
2022-05-23 11:11 [PATCH] firmware: arm_scmi: Avoid leak OF node on error cgel.zte
2022-05-23 11:53 ` Johan Hovold
@ 2022-05-23 13:27 ` Sudeep Holla
1 sibling, 0 replies; 3+ messages in thread
From: Sudeep Holla @ 2022-05-23 13:27 UTC (permalink / raw)
To: cgel.zte
Cc: cristian.marussi, linux-arm-kernel, Sudeep Holla, linux-kernel,
Minghao Chi, Zeal Robot
On Mon, May 23, 2022 at 11:11:16AM +0000, cgel.zte@gmail.com wrote:
> From: Minghao Chi <chi.minghao@zte.com.cn>
>
> The OF node should be put before returning error in smc_chan_available(),
> otherwise node's refcount will be leaked.
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
> ---
> drivers/firmware/arm_scmi/smc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
> index 745acfdd0b3d..43018be70edc 100644
> --- a/drivers/firmware/arm_scmi/smc.c
> +++ b/drivers/firmware/arm_scmi/smc.c
> @@ -55,10 +55,10 @@ static irqreturn_t smc_msg_done_isr(int irq, void *data)
> static bool smc_chan_available(struct device *dev, int idx)
> {
> struct device_node *np = of_parse_phandle(dev->of_node, "shmem", 0);
> + of_node_put(np);
While this may work as of_node_put handles NULL as argument, what is the
point of unnecessary of_node_put(NULL) here ?
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-23 13:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-23 11:11 [PATCH] firmware: arm_scmi: Avoid leak OF node on error cgel.zte
2022-05-23 11:53 ` Johan Hovold
2022-05-23 13:27 ` Sudeep Holla
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).