On Tue, Mar 12, 2019 at 10:54:33AM +0100, Uwe Kleine-König wrote:
> On Tue, Mar 12, 2019 at 10:49:59AM +0100, Geert Uytterhoeven wrote:
> > Hi Uwe,
> > 
> > On Tue, Mar 12, 2019 at 10:23 AM Uwe Kleine-König
> > <u.kleine-koe...@pengutronix.de> wrote:
> > > On Tue, Mar 12, 2019 at 12:16:34PM +0900, Yoshihiro Shimoda wrote:
> > > > diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> > > > index 1581f6a..2fdd6611 100644
> > > > --- a/drivers/pwm/core.c
> > > > +++ b/drivers/pwm/core.c
> > 
> > > > @@ -368,10 +370,12 @@ int pwmchip_remove(struct pwm_chip *chip)
> > > >
> > > >       free_pwms(chip);
> > > >
> > > > -     pwmchip_sysfs_unexport(chip);
> > > > -
> > > >  out:
> > > >       mutex_unlock(&pwm_lock);
> > > > +
> > > > +     if (!ret)
> > > > +             pwmchip_sysfs_unexport(chip);
> > > > +
> > >
> > > I wonder if this needs to be done before free_pwms is called. Otherwise
> > > the pwmchip is already gone and then something is requested via sysfs.
> > 
> > The chip itself is not freed, only the pwms array inside, which is not 
> > needed
> > for matching in pwmchip_sysfs_unexport(), right?
> 
> OK, then make this:
> 
> I wonder if pwmchip_sysfs_unexport needs to be done before free_pwms is
> called. Otherwise the PWMs's representation is already gone and then
> something might be requested via sysfs.

Agreed, I think sysfs needs to disappear before the chip does, otherwise
we could have userspace racing with the kernel for access to sysfs while
the PWM chip is already/only halfway gone.

Thierry

Attachment: signature.asc
Description: PGP signature

Reply via email to