Re: [PATCH] PM: Fix dev_pm_put_subsys_data() to not call kfree()while holding device power lock

From: Shuah Khan
Date: Mon May 06 2013 - 10:01:20 EST


On Mon, 2013-05-06 at 14:09 +0200, Pavel Machek wrote:
> Hi!
>
> > > Wow, that function is fragile. It returns 0/1/-EINVAL, while being
> > > documented for 0/1...
> >
> > Oh, it generally should return 1 for !psd.
> >
> > > Patch does not look obviously wrong, but maybe
> > >
> > > @@ -73,13 +73,17 @@ int dev_pm_put_subsys_data(struct device *dev)
> > >
> > > if (--psd->refcount == 0) {
> > > dev->power.subsys_data = NULL;
> > > + spin_unlock_irq(&dev->power.lock);
> > > - kfree(psd);
> > > - ret = 1;
> > > + return 1;
> > > }
> > >
> > > Would be cleaner.
> >
> > What about this:
>
> Looks good to me.
>
> Reviewed-by: Pavel Machek <pavel@xxxxxx>

Rafael/Pavel,

I redid the patch based on Pavel's comments and just about to send it
and then I saw your exchange. This version looks good to me. Do you want
me to test the patch and resend?

thanks,
-- Shuah
èº{.nÇ+‰·Ÿ®‰­†+%ŠËlzwm…ébëæìr¸›zX§»®w¥Š{ayºÊÚë,j­¢f£¢·hš‹àz¹®w¥¢¸ ¢·¦j:+v‰¨ŠwèjØm¶Ÿÿ¾«‘êçzZ+ƒùšŽŠÝj"ú!¶iO•æ¬z·švØ^¶m§ÿðà nÆàþY&—