Re: [PATCH v2] pinctrl: ocelot: Fix interrupt controller

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The 09/07/2022 11:36, Andy Shevchenko wrote:
> > +        * handler.
> > +        */
> > +       if (active && !ack) {
> > +               struct ocelot_irq_work *work;
> > +
> > +               work = kmalloc(sizeof(*work), GFP_ATOMIC);
> > +               if (!work)
> > +                       return;
> > +
> > +               work->irq_desc = desc;
> > +               INIT_WORK(&work->irq_work, ocelot_irq_work);
> > +               queue_work(system_wq, &work->irq_work);
> > +       }
> 
> Here I see potential issues with the object lifetime. 1) The memory is
> allocated here and what does guarantee its freeing? 2) What does
> guarantee that work will be not scheduled if the driver or its parts
> are gone?

You are right, if the driver is removed once the work is queued, then
that object will not be freed or even worst get NULL pointers.

A solution to this would be not to use system_wq but allocate own workqueue
and once the driver is removed, make sure to destroy it.
In this way we make sure that all the work is done.

> 
> --
> With Best Regards,
> Andy Shevchenko

-- 
/Horatiu



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux