From: Bart Van Assche via Intel-wired-lan <intel-wired-lan@osuosl.org>
To: Tony Nguyen <anthony.l.nguyen@intel.com>
Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com>,
intel-wired-lan@lists.osuosl.org,
Bart Van Assche <bvanassche@acm.org>,
Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Subject: [Intel-wired-lan] [PATCH iwl-net v4] ice: fix locking in ice_dcb_rebuild()
Date: Fri, 20 Mar 2026 14:28:24 -0700 [thread overview]
Message-ID: <20260320212824.264252-1-bvanassche@acm.org> (raw)
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: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Cc: intel-wired-lan@lists.osuosl.org
Fixes: 242b5e068b25 ("ice: Fix DCB rebuild after reset")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
v4 (this patch): Changed "[PATCH] iwl-net:" into "[PATCH iwl-net]".
v3 (2026-03-20): Modified patch description. See also
https://lore.kernel.org/all/20260223220102.2158611-20-bart.vanassche@linux.dev/#t
v2 (2026-02-23): Combined the two patches into one patch and
increased the amount of code covered by tc_mutex. See also
https://lore.kernel.org/all/20260223220102.2158611-20-bart.vanassche@linux.dev/
v1 (2025-02-06): Two patches. See also
https://lore.kernel.org/all/20250206175114.1974171-16-bvanassche@acm.org/
drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
index bd77f1c001ee..78ded6876581 100644
--- a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
@@ -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);
next reply other threads:[~2026-03-20 21:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 21:28 Bart Van Assche via Intel-wired-lan [this message]
2026-03-20 21:35 ` [Intel-wired-lan] [PATCH iwl-net v4] ice: fix locking in ice_dcb_rebuild() Loktionov, Aleksandr
2026-03-26 4:26 ` Przemek Kitszel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260320212824.264252-1-bvanassche@acm.org \
--to=intel-wired-lan@osuosl.org \
--cc=aleksandr.loktionov@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=bvanassche@acm.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=przemyslaw.kitszel@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox