Message ID | E1mRE2Z-001xhc-CB@rmk-PC.armlinux.org.uk (mailing list archive) |
---|---|
State | Accepted |
Commit | cbcca2e3961eac736566ac13ef0d0bf6f0b764ec |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next] net: phylink: don't call netif_carrier_off() with NULL netdev | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 1 maintainers not CCed: linux@armlinux.org.uk |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 11 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
Hello: This patch was applied to netdev/net-next.git (refs/heads/master): On Fri, 17 Sep 2021 14:36:31 +0100 you wrote: > Dan Carpenter points out that we have a code path that permits a NULL > netdev pointer to be passed to netif_carrier_off(), which will cause > a kernel oops. In any case, we need to set pl->old_link_state to false > to have the desired effect when there is no netdev present. > > Fixes: f97493657c63 ("net: phylink: add suspend/resume support") > Reported-by: Dan Carpenter <dan.carpenter@oracle.com> > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> > > [...] Here is the summary with links: - [net-next] net: phylink: don't call netif_carrier_off() with NULL netdev https://git.kernel.org/netdev/net-next/c/cbcca2e3961e You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 0a0abe8e4be0..5a58c77d0002 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1333,7 +1333,10 @@ void phylink_suspend(struct phylink *pl, bool mac_wol) * but one would hope all packets have been sent. This * also means phylink_resolve() will do nothing. */ - netif_carrier_off(pl->netdev); + if (pl->netdev) + netif_carrier_off(pl->netdev); + else + pl->old_link_state = false; /* We do not call mac_link_down() here as we want the * link to remain up to receive the WoL packets.
Dan Carpenter points out that we have a code path that permits a NULL netdev pointer to be passed to netif_carrier_off(), which will cause a kernel oops. In any case, we need to set pl->old_link_state to false to have the desired effect when there is no netdev present. Fixes: f97493657c63 ("net: phylink: add suspend/resume support") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> --- This does not need to be queued for -rc as there is only one user of phylink_suspend(), which will always have a non-NULL netdev pointer. Hence, submitting for net-next is appropriate. drivers/net/phy/phylink.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)