[Ksummit-discuss] [TECH TOPIC] Fix devm_kzalloc, its users, or both

Dmitry Torokhov dmitry.torokhov at gmail.com
Fri Aug 21 16:14:09 UTC 2015


On Fri, Aug 21, 2015 at 08:07:09AM -0700, Julia Lawall wrote:
> On Thu, 20 Aug 2015, Dmitry Torokhov wrote:
> 
> > On Fri, Jul 31, 2015 at 8:14 AM, Laurent Pinchart
> > <laurent.pinchart at ideasonboard.com> wrote:
> > > Hello,
> > >
> > > It recently came to my attention that the way devm_kzalloc() is used by most
> > > drivers is broken. I've raised the topic on LKML (see
> > > http://lkml.org/lkml/2015/7/14/741) in the hope that my findings were simply
> > > wrong, but it turned out I was unfortunately right. As the topic spans lots of
> > > subsystems I believe it would be a good technical topic for the Kernel Summit.
> >
> > <skip>
> >
> > Just realized another fun fact: most busses execute
> > dev_pm_domain_detach() in bus' remove() method, but devm-managed
> > resources (including interrupts and such) are only released in driver
> > core, which happens after bus' remove() method returns. So we may end
> > up shutting off PM domain of a device that is still active and may
> > generate interrupts, etc.
> 
> Can the PM call be devmified too?

I think they have to. I think everything in bus(es) code has to be
devm-ified if we want to allow devm in drivers.

> 
> What is there too the "etc"?  Would it be better to just remove the devm
> functions related to interrupts?  They seem to cause a lot of subtle
> problems.

And regulators, clocks, gpios... Even if we won't have interrupt coming
in someone may submit request to the device (userspace for example) and
we still may try accessing powered off or half-powered-off hardware.

Thanks.

-- 
Dmitry


More information about the Ksummit-discuss mailing list