linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][net-next] net: phy: check if advertising is zero using linkmode_empty
@ 2018-11-12 23:45 Colin King
  2018-11-13  0:18 ` Andrew Lunn
  2018-11-13  0:26 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2018-11-12 23:45 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, David S . Miller, netdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

A recent change modified variable advertising from a u32 to a link mode
array and left the u32 zero comparison, so essential we now have an array
being compared to null which is not the intention. Fix this by using the
call to linkmode_empty to check if advertising is all zero.

Detected by CoverityScan, CID#1475424 ("Array compared against 0")

Fixes: 3c1bcc8614db ("net: ethernet: Convert phydev advertize and supported from u32 to link mode")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/phy/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index d73873334e47..101b83d08864 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -328,7 +328,7 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev,
 	if (autoneg != AUTONEG_ENABLE && autoneg != AUTONEG_DISABLE)
 		return -EINVAL;
 
-	if (autoneg == AUTONEG_ENABLE && advertising == 0)
+	if (autoneg == AUTONEG_ENABLE && linkmode_empty(advertising))
 		return -EINVAL;
 
 	if (autoneg == AUTONEG_DISABLE &&
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][net-next] net: phy: check if advertising is zero using linkmode_empty
  2018-11-12 23:45 [PATCH][net-next] net: phy: check if advertising is zero using linkmode_empty Colin King
@ 2018-11-13  0:18 ` Andrew Lunn
  2018-11-13  0:26 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2018-11-13  0:18 UTC (permalink / raw)
  To: Colin King
  Cc: Florian Fainelli, David S . Miller, netdev, kernel-janitors,
	linux-kernel

On Mon, Nov 12, 2018 at 11:45:56PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> A recent change modified variable advertising from a u32 to a link mode
> array and left the u32 zero comparison, so essential we now have an array
> being compared to null which is not the intention. Fix this by using the
> call to linkmode_empty to check if advertising is all zero.
> 
> Detected by CoverityScan, CID#1475424 ("Array compared against 0")
> 
> Fixes: 3c1bcc8614db ("net: ethernet: Convert phydev advertize and supported from u32 to link mode")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Thanks Colin.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][net-next] net: phy: check if advertising is zero using linkmode_empty
  2018-11-12 23:45 [PATCH][net-next] net: phy: check if advertising is zero using linkmode_empty Colin King
  2018-11-13  0:18 ` Andrew Lunn
@ 2018-11-13  0:26 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-11-13  0:26 UTC (permalink / raw)
  To: colin.king; +Cc: andrew, f.fainelli, netdev, kernel-janitors, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Mon, 12 Nov 2018 23:45:56 +0000

> From: Colin Ian King <colin.king@canonical.com>
> 
> A recent change modified variable advertising from a u32 to a link mode
> array and left the u32 zero comparison, so essential we now have an array
> being compared to null which is not the intention. Fix this by using the
> call to linkmode_empty to check if advertising is all zero.
> 
> Detected by CoverityScan, CID#1475424 ("Array compared against 0")
> 
> Fixes: 3c1bcc8614db ("net: ethernet: Convert phydev advertize and supported from u32 to link mode")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-13  0:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-12 23:45 [PATCH][net-next] net: phy: check if advertising is zero using linkmode_empty Colin King
2018-11-13  0:18 ` Andrew Lunn
2018-11-13  0:26 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).