Skip to contentSkip to conversation

phylink: require valid state argument to phylink_validate_mask_caps()

PATCH Applied Jakub Kicinski 3 participants 3 messages Oct 25, 2022 – Oct 27, 2022

Subsystems (4)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 phylink: require valid state argument to phylink_validate_mask_caps()

state is deferenced earlier in the function, the NULL check is pointless. Since we don't have any crash reports presumably it's safe to assume state is not NULL.

Fixes f392a1846489 ("net: phylink: provide phylink_validate_mask_caps() helper")

---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 drivers/net/phy/phylink.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/phy/phylink.c +2 -3
index 62106c9e9a9d..88f60e98b760 100644
@@ -564,7 +564,7 @@ EXPORT_SYMBOL_GPL(phylink_get_capabilities);
 /**
  * phylink_validate_mask_caps() - Restrict link modes based on caps
  * @supported: ethtool bitmask for supported link modes.
- * @state: an (optional) pointer to a &struct phylink_link_state.
+ * @state: pointer to a &struct phylink_link_state.
  * @mac_capabilities: bitmask of MAC capabilities
  *
  * Calculate the supported link modes based on @mac_capabilities, and restrict
@@ -585,8 +585,7 @@ void phylink_validate_mask_caps(unsigned long *supported,
 	phylink_caps_to_linkmodes(mask, caps);
 
 	linkmode_and(supported, supported, mask);
-	if (state)
-		linkmode_and(state->advertising, state->advertising, mask);
+	linkmode_and(state->advertising, state->advertising, mask);
 }
 EXPORT_SYMBOL_GPL(phylink_validate_mask_caps);
 
Signature · 1 line
2.37.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Jakub Kicinski

state is deferenced earlier in the function, the NULL check is pointless. Since we don't have any crash reports presumably it's safe to assume state is not NULL.

Yes, I believe this was in place just for a patch which hasn't been upstreamed.

Quoted 26 lines
Fixes f392a1846489 ("net: phylink: provide phylink_validate_mask_caps() helper")

---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 drivers/net/phy/phylink.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/phy/phylink.c +1 -1
index 62106c9e9a9d..88f60e98b760 100644
@@ -564,7 +564,7 @@ EXPORT_SYMBOL_GPL(phylink_get_capabilities);
 /**
  * phylink_validate_mask_caps() - Restrict link modes based on caps
  * @supported: ethtool bitmask for supported link modes.
- * @state: an (optional) pointer to a &struct phylink_link_state.
+ * @state: pointer to a &struct phylink_link_state.
  * @mac_capabilities: bitmask of MAC capabilities
  *
  * Calculate the supported link modes based on @mac_capabilities, and restrict

drivers/net/phy/phylink.c void phylink_validate_mask_caps(unsigned long *supported, · line 591

Quoted 9 lines
drivers/net/phy/phylink.c +1 -2
@@ -585,8 +585,7 @@ void phylink_validate_mask_caps(unsigned long *supported,
 	phylink_caps_to_linkmodes(mask, caps);
 
 	linkmode_and(supported, supported, mask);
-	if (state)
-		linkmode_and(state->advertising, state->advertising, mask);
+	linkmode_and(state->advertising, state->advertising, mask);
 }
 EXPORT_SYMBOL_GPL(phylink_validate_mask_caps);
 
#2 lore raw
In reply to Jakub Kicinski
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 8 lines · On Tue, 25 Oct 2022 11:51:26 -0700 you wrote:

state is deferenced earlier in the function, the NULL check is pointless. Since we don't have any crash reports presumably it's safe to assume state is not NULL.

Fixes f392a1846489 ("net: phylink: provide phylink_validate_mask_caps() helper")

[...]

Here is the summary with links:
- [net-next] phylink: require valid state argument to phylink_validate_mask_caps()

    https://git.kernel.org/netdev/net-next/c/e0b3ef17f45e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html