diff mbox series

ethtool: Fix refcount leak in gfar_get_ts_info

Message ID 20220309091149.775-1-linmq006@gmail.com (mailing list archive)
State Changes Requested
Commit 2ac5b58e645c66932438bb021cb5b52097ce70b0
Delegated to: Netdev Maintainers
Headers show
Series ethtool: Fix refcount leak in gfar_get_ts_info | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Miaoqian Lin March 9, 2022, 9:11 a.m. UTC
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 <linmq006@gmail.com>
---
 drivers/net/ethernet/freescale/gianfar_ethtool.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Jesse Brandeburg March 9, 2022, 8:19 p.m. UTC | #1
> 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 <linmq006@gmail.com>
> ---
>   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 <jesse.brandeburg@intel.com>
patchwork-bot+netdevbpf@kernel.org March 10, 2022, 8:30 p.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

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 <linmq006@gmail.com>
> 
> [...]

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!
Jakub Kicinski March 10, 2022, 8:36 p.m. UTC | #3
On Thu, 10 Mar 2022 20:30:10 +0000 patchwork-bot+netdevbpf@kernel.org
wrote:
> Hello:
> 
> This patch was applied to netdev/net.git (master)
> by Jakub Kicinski <kuba@kernel.org>:

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 <linmq006@gmail.com>
> > 
> > [...]  
> 
> 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!
diff mbox series

Patch

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);
 	}