public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: Aleksandr Loktionov <aleksandr.loktionov@intel.com>,
	Bart Van Assche <bvanassche@acm.org>
Cc: <netdev@vger.kernel.org>, <intel-wired-lan@lists.osuosl.org>,
	"Katarzyna Wieczerzycka" <katarzyna.wieczerzycka@intel.com>,
	<anthony.l.nguyen@intel.com>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next] ice: call mutex_lock() before mutex_unlock() in ice_dcb_rebuild()
Date: Fri, 20 Mar 2026 11:13:15 +0100	[thread overview]
Message-ID: <4b1927b5-2a3c-4465-9181-2e8885afd122@intel.com> (raw)
In-Reply-To: <20260320050522.422355-1-aleksandr.loktionov@intel.com>

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);
>   


  reply	other threads:[~2026-03-20 10:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-03-26 14:26   ` [Intel-wired-lan] " Loktionov, Aleksandr

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=4b1927b5-2a3c-4465-9181-2e8885afd122@intel.com \
    --to=przemyslaw.kitszel@intel.com \
    --cc=aleksandr.loktionov@intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=bvanassche@acm.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=katarzyna.wieczerzycka@intel.com \
    --cc=netdev@vger.kernel.org \
    /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