phylink: require valid state argument to phylink_validate_mask_caps()
authorJakub Kicinski <kuba@kernel.org>
Tue, 25 Oct 2022 18:51:26 +0000 (11:51 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 27 Oct 2022 02:07:43 +0000 (19:07 -0700)
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")
Reviewed-by: Sean Anderson <sean.anderson@seco.com>
Link: https://lore.kernel.org/r/20221025185126.1720553-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/phylink.c

index 62106c9e9a9d2cd4ae2a8174d7be3161f7f166f6..88f60e98b7602cc3dc02c40a00cb5bf004c3b302 100644 (file)
@@ -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);