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 <[email protected]>
> 
> 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

Reply via email to