]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ice: fix AQ error code comparison in ice_set_pauseparam()
authorLukasz Czapnik <lukasz.czapnik@intel.com>
Fri, 27 Mar 2026 07:22:35 +0000 (08:22 +0100)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Mon, 22 Jun 2026 21:04:01 +0000 (14:04 -0700)
Fix unreachable code: the conditionals in ice_set_pauseparam() used
the bitwise-AND operator suggesting aq_failures is a bitmap, but it
is actually an enum, making the third condition logically unreachable.

Replace the if-else ladder with a switch statement.  Also move the
aq_failures initialization to the variable declaration and remove the
redundant zeroing from ice_set_fc().

Fixes: fcea6f3da546 ("ice: Add stats and ethtool support")
Signed-off-by: Lukasz Czapnik <lukasz.czapnik@intel.com>
Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_common.c
drivers/net/ethernet/intel/ice/ice_ethtool.c

index 31e0de9e7f6075e1f8db532c169af8bae4a0db39..ef1ce106f81b5ecc4c7816b92174587cd404e577 100644 (file)
@@ -3882,7 +3882,6 @@ ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool ena_auto_link_update)
        if (!pi || !aq_failures)
                return -EINVAL;
 
-       *aq_failures = 0;
        hw = pi->hw;
 
        pcaps = kzalloc_obj(*pcaps);
index 236d293aba984a800d167832c1629aa5ded8fe55..49371b065845820348e29d9699f8bfd0c178beeb 100644 (file)
@@ -3508,7 +3508,7 @@ ice_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause)
        struct ice_vsi *vsi = np->vsi;
        struct ice_hw *hw = &pf->hw;
        struct ice_port_info *pi;
-       u8 aq_failures;
+       u8 aq_failures = 0;
        bool link_up;
        u32 is_an;
        int err;
@@ -3579,18 +3579,22 @@ ice_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause)
        /* Set the FC mode and only restart AN if link is up */
        err = ice_set_fc(pi, &aq_failures, link_up);
 
-       if (aq_failures & ICE_SET_FC_AQ_FAIL_GET) {
+       switch (aq_failures) {
+       case ICE_SET_FC_AQ_FAIL_GET:
                netdev_info(netdev, "Set fc failed on the get_phy_capabilities call with err %d aq_err %s\n",
                            err, libie_aq_str(hw->adminq.sq_last_status));
                err = -EAGAIN;
-       } else if (aq_failures & ICE_SET_FC_AQ_FAIL_SET) {
+               break;
+       case ICE_SET_FC_AQ_FAIL_SET:
                netdev_info(netdev, "Set fc failed on the set_phy_config call with err %d aq_err %s\n",
                            err, libie_aq_str(hw->adminq.sq_last_status));
                err = -EAGAIN;
-       } else if (aq_failures & ICE_SET_FC_AQ_FAIL_UPDATE) {
+               break;
+       case ICE_SET_FC_AQ_FAIL_UPDATE:
                netdev_info(netdev, "Set fc failed on the get_link_info call with err %d aq_err %s\n",
                            err, libie_aq_str(hw->adminq.sq_last_status));
                err = -EAGAIN;
+               break;
        }
 
        return err;