From: Andrew Lunn <andrew@lunn.ch>
To: Kohei Enju <kohei@enjuk.jp>
Cc: Ayush Yaduvanshi <ayush37735@gmail.com>,
anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com,
intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: intel: ice: Modernize ice_vsi_free() with scope-based guard(mutex)
Date: Wed, 14 Oct 2026 22:22:20 +0200 [thread overview]
Message-ID: <0079adea-1e94-4fa7-8956-a4b4a32805b5@lunn.ch> (raw)
In-Reply-To: <as-tT0nDrchWa96T@x1>
On Thu, Oct 15, 2026 at 01:36:35AM +0900, Kohei Enju wrote:
> On 10/14 16:35, Ayush Yaduvanshi wrote:
> > Signed-off-by: Ayush Yaduvanshi <ayush37735@gmail.com>
>
> The commit message is missing, and this patch seems to be a clean-up
> patch, which is discouraged in
> Documentation/process/maintainer-netdev.rst. Also, this document says:
> Use of ``guard()`` is discouraged within any function longer than 20 lines
>
> > ---
> > drivers/net/ethernet/intel/ice/ice_lib.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
> > index 9e08db376d3d..c695df442822 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_lib.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_lib.c
> > @@ -457,7 +457,7 @@ void ice_vsi_free(struct ice_vsi *vsi)
> > return;
> > }
> >
> > - mutex_lock(&pf->sw_mutex);
> > + guard(mutex)(&pf->sw_mutex);
> > /* updates the PF for this cleared VSI */
> >
> > pf->vsi[vsi->idx] = NULL;
> > @@ -466,7 +466,6 @@ void ice_vsi_free(struct ice_vsi *vsi)
> > ice_vsi_free_stats(vsi);
> > ice_vsi_free_arrays(vsi);
> > mutex_destroy(&vsi->xdp_state_lock);
> > - mutex_unlock(&pf->sw_mutex);
> > devm_kfree(dev, vsi);
>
> This also extends the critical section, as devm_kfree() is now called
> while holding pf->sw_mutex.
This is exactly why guard() is bad and should not be used.
Andrew
prev parent reply other threads:[~2026-10-14 20:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 11:05 Ayush Yaduvanshi
2026-10-14 16:36 ` Kohei Enju
2026-10-14 20:22 ` Andrew Lunn [this message]
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=0079adea-1e94-4fa7-8956-a4b4a32805b5@lunn.ch \
--to=andrew@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=ayush37735@gmail.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kohei@enjuk.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.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
all inboxes | Powered by JetHome®