diff mbox series

[v2,3/3] qlogic: qlcnic: fix use of SPEED_UNKNOWN ethtool constant

Message ID 1554734927-15522-4-git-send-email-mzhivich@akamai.com
State Accepted
Delegated to: David Miller
Headers show
Series ethtool: fix use of SPEED_UNKNOWN constant | expand

Commit Message

Michael Zhivich April 8, 2019, 2:48 p.m. UTC
qlcnic driver uses u16 to store SPEED_UKNOWN ethtool constant,
which is defined as -1, resulting in value truncation and
thus incorrect test results against SPEED_UNKNOWN.

For example, the following test will print "False":

    u16 speed = SPEED_UNKNOWN;

    if (speed == SPEED_UNKNOWN)
        printf("True");
    else
        printf("False");

Change storage of speed to use u32 to avoid this issue.

Signed-off-by: Michael Zhivich <mzhivich@akamai.com>
---
 drivers/net/ethernet/qlogic/qlcnic/qlcnic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Lunn April 8, 2019, 5:53 p.m. UTC | #1
On Mon, Apr 08, 2019 at 10:48:47AM -0400, Michael Zhivich wrote:
> qlcnic driver uses u16 to store SPEED_UKNOWN ethtool constant,
> which is defined as -1, resulting in value truncation and
> thus incorrect test results against SPEED_UNKNOWN.
> 
> For example, the following test will print "False":
> 
>     u16 speed = SPEED_UNKNOWN;
> 
>     if (speed == SPEED_UNKNOWN)
>         printf("True");
>     else
>         printf("False");
> 
> Change storage of speed to use u32 to avoid this issue.
> 
> Signed-off-by: Michael Zhivich <mzhivich@akamai.com>

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

    Andrew
diff mbox series

Patch

diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
index 0c443ea..374a4d4 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
@@ -497,7 +497,7 @@  struct qlcnic_hardware_context {
 	u16 board_type;
 	u16 supported_type;
 
-	u16 link_speed;
+	u32 link_speed;
 	u16 link_duplex;
 	u16 link_autoneg;
 	u16 module_type;