* [PATCH iwl-next] ice: call mutex_lock() before mutex_unlock() in ice_dcb_rebuild()
@ 2026-03-20 5:05 Aleksandr Loktionov
2026-03-20 10:13 ` [Intel-wired-lan] " Przemek Kitszel
0 siblings, 1 reply; 3+ messages in thread
From: Aleksandr Loktionov @ 2026-03-20 5:05 UTC (permalink / raw)
To: intel-wired-lan, anthony.l.nguyen, aleksandr.loktionov
Cc: netdev, Katarzyna Wieczerzycka
From: Katarzyna Wieczerzycka <katarzyna.wieczerzycka@intel.com>
In ice_dcb_rebuild(), the first call to ice_query_port_ets() is checked
for error, and on failure jumps to the 'dcb_error' label. The error path
always calls mutex_unlock(&pf->tc_mutex), but at this point in the code
the mutex has never been locked -- mutex_lock() came after the check.
Releasing a mutex that was not locked is undefined behaviour and can
cause a deadlock or crash. Fix this by moving mutex_lock() to before
the error check, so that 'dcb_error' always pairs with a prior lock.
Fixes: 242b5e068b25 ("ice: Fix DCB rebuild after reset")
Signed-off-by: Katarzyna Wieczerzycka <katarzyna.wieczerzycka@intel.com>
Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
---
drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 3 +--
1 file changed, 1 insertion(+), 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 bd77f1c..d516734 100644
--- a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
@@ -538,12 +538,11 @@ void ice_dcb_rebuild(struct ice_pf *pf)
int ret;
ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL);
+ mutex_lock(&pf->tc_mutex);
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);
--
2.52.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Intel-wired-lan] [PATCH iwl-next] ice: call mutex_lock() before mutex_unlock() in ice_dcb_rebuild()
2026-03-20 5:05 [PATCH iwl-next] ice: call mutex_lock() before mutex_unlock() in ice_dcb_rebuild() Aleksandr Loktionov
@ 2026-03-20 10:13 ` Przemek Kitszel
2026-03-26 14:26 ` Loktionov, Aleksandr
0 siblings, 1 reply; 3+ messages in thread
From: Przemek Kitszel @ 2026-03-20 10:13 UTC (permalink / raw)
To: Aleksandr Loktionov, Bart Van Assche
Cc: netdev, intel-wired-lan, Katarzyna Wieczerzycka, anthony.l.nguyen
On 3/20/26 06:05, Aleksandr Loktionov wrote:
> From: Katarzyna Wieczerzycka <katarzyna.wieczerzycka@intel.com>
>
> In ice_dcb_rebuild(), the first call to ice_query_port_ets() is checked
> for error, and on failure jumps to the 'dcb_error' label. The error path
> always calls mutex_unlock(&pf->tc_mutex), but at this point in the code
> the mutex has never been locked -- mutex_lock() came after the check.
>
> Releasing a mutex that was not locked is undefined behaviour and can
> cause a deadlock or crash. Fix this by moving mutex_lock() to before
> the error check, so that 'dcb_error' always pairs with a prior lock.
>
> Fixes: 242b5e068b25 ("ice: Fix DCB rebuild after reset")
> Signed-off-by: Katarzyna Wieczerzycka <katarzyna.wieczerzycka@intel.com>
> Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
NACK
there is a better fix proposed by community, we are awaiting v2
https://patchew.org/linux/20260223220102.2158611-1-bart.vanassche@linux.dev/20260223220102.2158611-20-bart.vanassche@linux.dev/
> ---
> drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 3 +--
> 1 file changed, 1 insertion(+), 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 bd77f1c..d516734 100644
> --- a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
> @@ -538,12 +538,11 @@ void ice_dcb_rebuild(struct ice_pf *pf)
> int ret;
>
> ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL);
the difference is to move mutex_lock() over ice_query_port_ets()
> + mutex_lock(&pf->tc_mutex);
> 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);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [Intel-wired-lan] [PATCH iwl-next] ice: call mutex_lock() before mutex_unlock() in ice_dcb_rebuild()
2026-03-20 10:13 ` [Intel-wired-lan] " Przemek Kitszel
@ 2026-03-26 14:26 ` Loktionov, Aleksandr
0 siblings, 0 replies; 3+ messages in thread
From: Loktionov, Aleksandr @ 2026-03-26 14:26 UTC (permalink / raw)
To: Kitszel, Przemyslaw, Bart Van Assche
Cc: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org,
Wieczerzycka, Katarzyna, Nguyen, Anthony L
> -----Original Message-----
> From: Kitszel, Przemyslaw <przemyslaw.kitszel@intel.com>
> Sent: Friday, March 20, 2026 11:13 AM
> To: Loktionov, Aleksandr <aleksandr.loktionov@intel.com>; Bart Van
> Assche <bvanassche@acm.org>
> Cc: netdev@vger.kernel.org; intel-wired-lan@lists.osuosl.org;
> Wieczerzycka, Katarzyna <katarzyna.wieczerzycka@intel.com>; Nguyen,
> Anthony L <anthony.l.nguyen@intel.com>
> Subject: Re: [Intel-wired-lan] [PATCH iwl-next] ice: call mutex_lock()
> before mutex_unlock() in ice_dcb_rebuild()
>
> On 3/20/26 06:05, Aleksandr Loktionov wrote:
> > From: Katarzyna Wieczerzycka <katarzyna.wieczerzycka@intel.com>
> >
> > In ice_dcb_rebuild(), the first call to ice_query_port_ets() is
> > checked for error, and on failure jumps to the 'dcb_error' label.
> The
> > error path always calls mutex_unlock(&pf->tc_mutex), but at this
> point
> > in the code the mutex has never been locked -- mutex_lock() came
> after the check.
> >
> > Releasing a mutex that was not locked is undefined behaviour and can
> > cause a deadlock or crash. Fix this by moving mutex_lock() to before
> > the error check, so that 'dcb_error' always pairs with a prior lock.
> >
> > Fixes: 242b5e068b25 ("ice: Fix DCB rebuild after reset")
> > Signed-off-by: Katarzyna Wieczerzycka
> > <katarzyna.wieczerzycka@intel.com>
> > Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
>
> NACK
>
> there is a better fix proposed by community, we are awaiting v2
> https://patchew.org/linux/20260223220102.2158611-1-
> bart.vanassche@linux.dev/20260223220102.2158611-20-
> bart.vanassche@linux.dev/
>
> > ---
> > drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 3 +--
> > 1 file changed, 1 insertion(+), 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 bd77f1c..d516734 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
> > @@ -538,12 +538,11 @@ void ice_dcb_rebuild(struct ice_pf *pf)
> > int ret;
> >
> > ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf),
> > NULL);
>
> the difference is to move mutex_lock() over ice_query_port_ets()
>
> > + mutex_lock(&pf->tc_mutex);
> > 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);
> >
Withdrawing this patch (just in case NACK is not enough).
Bart Van Assche's series covers the same fix with a more complete
approach (moving mutex_lock() above ice_query_port_ets()). His v4
has been reviewed and accepted.
With the best regards
Alex
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-26 14:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 5:05 [PATCH iwl-next] ice: call mutex_lock() before mutex_unlock() in ice_dcb_rebuild() Aleksandr Loktionov
2026-03-20 10:13 ` [Intel-wired-lan] " Przemek Kitszel
2026-03-26 14:26 ` Loktionov, Aleksandr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox