diff mbox series

[net,v2] net: lan966x: remove debugfs directory in probe() error path

Message ID 20240513111853.58668-1-herve.codina@bootlin.com (mailing list archive)
State Accepted
Commit 99975ad644c7836414183fa7be4f883a4fb2bf64
Delegated to: Netdev Maintainers
Headers show
Series [net,v2] net: lan966x: remove debugfs directory in probe() error path | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 925 this patch: 925
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 936 this patch: 936
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 936 this patch: 936
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 24 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-05-14--00-00 (tests: 1022)

Commit Message

Herve Codina May 13, 2024, 11:18 a.m. UTC
A debugfs directory entry is create early during probe(). This entry is
not removed on error path leading to some "already present" issues in
case of EPROBE_DEFER.

Create this entry later in the probe() code to avoid the need to change
many 'return' in 'goto' and add the removal in the already present error
path.

Fixes: 942814840127 ("net: lan966x: Add VCAP debugFS support")
Cc: <stable@vger.kernel.org>
Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Horatiu Vultur May 13, 2024, 11:44 a.m. UTC | #1
Hi,

The 05/13/2024 13:18, Herve Codina wrote:
> 
> A debugfs directory entry is create early during probe(). This entry is
> not removed on error path leading to some "already present" issues in
> case of EPROBE_DEFER.
> 
> Create this entry later in the probe() code to avoid the need to change
> many 'return' in 'goto' and add the removal in the already present error
> path.
> 
> Fixes: 942814840127 ("net: lan966x: Add VCAP debugFS support")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Herve Codina <herve.codina@bootlin.com>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>

This looks OK to me. As the debugfs_root is used inside lan966x_vcap_init
which is called at the end of the probe.

Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>

> ---
>  drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> index 2635ef8958c8..61d88207eed4 100644
> --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> @@ -1087,8 +1087,6 @@ static int lan966x_probe(struct platform_device *pdev)
>         platform_set_drvdata(pdev, lan966x);
>         lan966x->dev = &pdev->dev;
> 
> -       lan966x->debugfs_root = debugfs_create_dir("lan966x", NULL);
> -
>         if (!device_get_mac_address(&pdev->dev, mac_addr)) {
>                 ether_addr_copy(lan966x->base_mac, mac_addr);
>         } else {
> @@ -1179,6 +1177,8 @@ static int lan966x_probe(struct platform_device *pdev)
>                 return dev_err_probe(&pdev->dev, -ENODEV,
>                                      "no ethernet-ports child found\n");
> 
> +       lan966x->debugfs_root = debugfs_create_dir("lan966x", NULL);
> +
>         /* init switch */
>         lan966x_init(lan966x);
>         lan966x_stats_init(lan966x);
> @@ -1257,6 +1257,8 @@ static int lan966x_probe(struct platform_device *pdev)
>         destroy_workqueue(lan966x->stats_queue);
>         mutex_destroy(&lan966x->stats_lock);
> 
> +       debugfs_remove_recursive(lan966x->debugfs_root);
> +
>         return err;
>  }
> 
> --
> 
> This patch was previously sent as part of a bigger series:
>   https://lore.kernel.org/lkml/20240430083730.134918-9-herve.codina@bootlin.com/
> As it is a simple fix, this v2 is the patch extracted from the series
> and sent alone to net.
> 
> Changes v1 -> v2
>   Add 'Reviewed-by: Andrew Lunn <andrew@lunn.ch>'
> 
> 2.44.0
patchwork-bot+netdevbpf@kernel.org May 16, 2024, 8:50 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Mon, 13 May 2024 13:18:53 +0200 you wrote:
> A debugfs directory entry is create early during probe(). This entry is
> not removed on error path leading to some "already present" issues in
> case of EPROBE_DEFER.
> 
> Create this entry later in the probe() code to avoid the need to change
> many 'return' in 'goto' and add the removal in the already present error
> path.
> 
> [...]

Here is the summary with links:
  - [net,v2] net: lan966x: remove debugfs directory in probe() error path
    https://git.kernel.org/netdev/net/c/99975ad644c7

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
index 2635ef8958c8..61d88207eed4 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
@@ -1087,8 +1087,6 @@  static int lan966x_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, lan966x);
 	lan966x->dev = &pdev->dev;
 
-	lan966x->debugfs_root = debugfs_create_dir("lan966x", NULL);
-
 	if (!device_get_mac_address(&pdev->dev, mac_addr)) {
 		ether_addr_copy(lan966x->base_mac, mac_addr);
 	} else {
@@ -1179,6 +1177,8 @@  static int lan966x_probe(struct platform_device *pdev)
 		return dev_err_probe(&pdev->dev, -ENODEV,
 				     "no ethernet-ports child found\n");
 
+	lan966x->debugfs_root = debugfs_create_dir("lan966x", NULL);
+
 	/* init switch */
 	lan966x_init(lan966x);
 	lan966x_stats_init(lan966x);
@@ -1257,6 +1257,8 @@  static int lan966x_probe(struct platform_device *pdev)
 	destroy_workqueue(lan966x->stats_queue);
 	mutex_destroy(&lan966x->stats_lock);
 
+	debugfs_remove_recursive(lan966x->debugfs_root);
+
 	return err;
 }