]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ice: fix locking in ice_dcb_rebuild()
authorBart Van Assche <bvanassche@acm.org>
Wed, 6 May 2026 21:48:15 +0000 (14:48 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 8 May 2026 23:01:09 +0000 (16:01 -0700)
Move the mutex_lock() call up to prevent that DCB settings change after
the first ice_query_port_ets() call. The second ice_query_port_ets()
call in ice_dcb_rebuild() is already protected by pf->tc_mutex.

This also fixes a bug in an error path, as before taking the first
"goto dcb_error" in the function jumped over mutex_lock() to
mutex_unlock().

This bug has been detected by the clang thread-safety analyzer.

Cc: intel-wired-lan@lists.osuosl.org
Fixes: 242b5e068b25 ("ice: Fix DCB rebuild after reset")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Tested-by: Arpana Arland <arpanax.arland@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://patch.msgid.link/20260506-jk-iwl-net-2026-05-04-v2-6-a5ea4dc837a9@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/intel/ice/ice_dcb_lib.c

index 16aa255351523d1a21123e417e5f34cc48e3a1b2..0bc6dd37568792cf9368d9510180e4f71491ee02 100644 (file)
@@ -537,14 +537,14 @@ void ice_dcb_rebuild(struct ice_pf *pf)
        struct ice_dcbx_cfg *err_cfg;
        int ret;
 
+       mutex_lock(&pf->tc_mutex);
+
        ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL);
        if (ret) {
                dev_err(dev, "Query Port ETS failed\n");
                goto dcb_error;
        }
 
-       mutex_lock(&pf->tc_mutex);
-
        if (!pf->hw.port_info->qos_cfg.is_sw_lldp)
                ice_cfg_etsrec_defaults(pf->hw.port_info);