2022-03-09 09:28:24

by Miaoqian Lin

[permalink] [raw]
Subject: [PATCH] ethtool: Fix refcount leak in gfar_get_ts_info

The of_find_compatible_node() function returns a node pointer with
refcount incremented, We should use of_node_put() on it when done
Add the missing of_node_put() to release the refcount.

Fixes: 7349a74ea75c ("net: ethernet: gianfar_ethtool: get phc index through drvdata")
Signed-off-by: Miaoqian Lin <[email protected]>
---
drivers/net/ethernet/freescale/gianfar_ethtool.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index ff756265d58f..9a2c16d69e2c 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -1464,6 +1464,7 @@ static int gfar_get_ts_info(struct net_device *dev,
ptp_node = of_find_compatible_node(NULL, NULL, "fsl,etsec-ptp");
if (ptp_node) {
ptp_dev = of_find_device_by_node(ptp_node);
+ of_node_put(ptp_node);
if (ptp_dev)
ptp = platform_get_drvdata(ptp_dev);
}
--
2.17.1


2022-03-10 14:27:11

by Jesse Brandeburg

[permalink] [raw]
Subject: Re: [PATCH] ethtool: Fix refcount leak in gfar_get_ts_info

> Subject: [PATCH] ethtool: Fix refcount leak in gfar_get_ts_info

should be:
[PATCH net v2] gianfar: ethtool: Fix refcount leak in gfar_get_ts_info

On 3/9/2022 1:11 AM, Miaoqian Lin wrote:
> The of_find_compatible_node() function returns a node pointer with
> refcount incremented, We should use of_node_put() on it when done
> Add the missing of_node_put() to release the refcount.
>
> Fixes: 7349a74ea75c ("net: ethernet: gianfar_ethtool: get phc index through drvdata")
> Signed-off-by: Miaoqian Lin <[email protected]>
> ---
> drivers/net/ethernet/freescale/gianfar_ethtool.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
> index ff756265d58f..9a2c16d69e2c 100644
> --- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
> +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
> @@ -1464,6 +1464,7 @@ static int gfar_get_ts_info(struct net_device *dev,
> ptp_node = of_find_compatible_node(NULL, NULL, "fsl,etsec-ptp");
> if (ptp_node) {
> ptp_dev = of_find_device_by_node(ptp_node);
> + of_node_put(ptp_node);
> if (ptp_dev)
> ptp = platform_get_drvdata(ptp_dev);
> }

If you fix the subject and resend a v2, you can add
Reviewed-by: Jesse Brandeburg <[email protected]>

2022-03-11 07:38:56

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH] ethtool: Fix refcount leak in gfar_get_ts_info

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

On Wed, 9 Mar 2022 09:11:49 +0000 you wrote:
> The of_find_compatible_node() function returns a node pointer with
> refcount incremented, We should use of_node_put() on it when done
> Add the missing of_node_put() to release the refcount.
>
> Fixes: 7349a74ea75c ("net: ethernet: gianfar_ethtool: get phc index through drvdata")
> Signed-off-by: Miaoqian Lin <[email protected]>
>
> [...]

Here is the summary with links:
- ethtool: Fix refcount leak in gfar_get_ts_info
https://git.kernel.org/netdev/net/c/2ac5b58e645c

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html


2022-03-11 08:43:20

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH] ethtool: Fix refcount leak in gfar_get_ts_info

On Thu, 10 Mar 2022 20:30:10 +0000 [email protected]
wrote:
> Hello:
>
> This patch was applied to netdev/net.git (master)
> by Jakub Kicinski <[email protected]>:

No, it wasn't. Maybe I forgot to mark this version as Changes Requested
before applying v2.

> On Wed, 9 Mar 2022 09:11:49 +0000 you wrote:
> > The of_find_compatible_node() function returns a node pointer with
> > refcount incremented, We should use of_node_put() on it when done
> > Add the missing of_node_put() to release the refcount.
> >
> > Fixes: 7349a74ea75c ("net: ethernet: gianfar_ethtool: get phc index through drvdata")
> > Signed-off-by: Miaoqian Lin <[email protected]>
> >
> > [...]
>
> Here is the summary with links:
> - ethtool: Fix refcount leak in gfar_get_ts_info
> https://git.kernel.org/netdev/net/c/2ac5b58e645c
>
> You are awesome, thank you!