diff mbox series

[net,2/2] net: sh_eth: Fix missing rtnl lock in suspend path

Message ID 20250122-fix_missing_rtnl_lock_phy_disconnect-v1-2-8cb9f6f88fd1@bootlin.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Fix missing rtnl lock in suspend path | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
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: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 1 this patch: 1
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: 38 this patch: 38
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-2025-01-22--21-00 (tests: 885)

Commit Message

Kory Maincent Jan. 22, 2025, 4:19 p.m. UTC
Fix the suspend path by ensuring the rtnl lock is held where required.
Calls to sh_eth_close, sh_eth_open and wol operations must be performed
under the rtnl lock to prevent conflicts with ongoing ndo operations.

Fixes: b71af04676e9 ("sh_eth: add more PM methods")
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---
 drivers/net/ethernet/renesas/sh_eth.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Niklas Söderlund Jan. 22, 2025, 5:12 p.m. UTC | #1
Hi Kory,

Thanks for your work.

On 2025-01-22 17:19:29 +0100, Kory Maincent wrote:
> Fix the suspend path by ensuring the rtnl lock is held where required.
> Calls to sh_eth_close, sh_eth_open and wol operations must be performed
> under the rtnl lock to prevent conflicts with ongoing ndo operations.
> 
> Fixes: b71af04676e9 ("sh_eth: add more PM methods")
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>

Tested on R-Car M2,

Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---
>  drivers/net/ethernet/renesas/sh_eth.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
> index 8887b8921009..5fc8027c92c7 100644
> --- a/drivers/net/ethernet/renesas/sh_eth.c
> +++ b/drivers/net/ethernet/renesas/sh_eth.c
> @@ -3494,10 +3494,12 @@ static int sh_eth_suspend(struct device *dev)
>  
>  	netif_device_detach(ndev);
>  
> +	rtnl_lock();
>  	if (mdp->wol_enabled)
>  		ret = sh_eth_wol_setup(ndev);
>  	else
>  		ret = sh_eth_close(ndev);
> +	rtnl_unlock();
>  
>  	return ret;
>  }
> @@ -3511,10 +3513,12 @@ static int sh_eth_resume(struct device *dev)
>  	if (!netif_running(ndev))
>  		return 0;
>  
> +	rtnl_lock();
>  	if (mdp->wol_enabled)
>  		ret = sh_eth_wol_restore(ndev);
>  	else
>  		ret = sh_eth_open(ndev);
> +	rtnl_unlock();
>  
>  	if (ret < 0)
>  		return ret;
> 
> -- 
> 2.34.1
>
Sergey Shtylyov Jan. 22, 2025, 6:39 p.m. UTC | #2
On 1/22/25 7:19 PM, Kory Maincent wrote:

> Fix the suspend path by ensuring the rtnl lock is held where required.

   Maybe suspend/resume path (the same w/the subject)?

> Calls to sh_eth_close, sh_eth_open and wol operations must be performed
> under the rtnl lock to prevent conflicts with ongoing ndo operations.
> 
> Fixes: b71af04676e9 ("sh_eth: add more PM methods")
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>

    FWIW:

Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>

[...]

MBR, Sergey
diff mbox series

Patch

diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 8887b8921009..5fc8027c92c7 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -3494,10 +3494,12 @@  static int sh_eth_suspend(struct device *dev)
 
 	netif_device_detach(ndev);
 
+	rtnl_lock();
 	if (mdp->wol_enabled)
 		ret = sh_eth_wol_setup(ndev);
 	else
 		ret = sh_eth_close(ndev);
+	rtnl_unlock();
 
 	return ret;
 }
@@ -3511,10 +3513,12 @@  static int sh_eth_resume(struct device *dev)
 	if (!netif_running(ndev))
 		return 0;
 
+	rtnl_lock();
 	if (mdp->wol_enabled)
 		ret = sh_eth_wol_restore(ndev);
 	else
 		ret = sh_eth_open(ndev);
+	rtnl_unlock();
 
 	if (ret < 0)
 		return ret;