mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Horatiu Vultur <horatiu.vultur@microchip.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>
Subject: Re: [PATCH v2] pinctrl: ocelot: Fix interrupt controller
Date: Wed, 7 Sep 2022 21:47:54 +0200	[thread overview]
Message-ID: <20220907194754.nw4jpghsjzuz2jcu@soft-dev3-1.localhost> (raw)
In-Reply-To: <CAHp75VecfNvj3Ji1ivZk3cpwbpr8F4FX0xR5H+=CjAO_o-uuxw@mail.gmail.com>

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

  reply	other threads:[~2022-09-07 19:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-07  8:02 Horatiu Vultur
2022-09-07  8:36 ` Andy Shevchenko
2022-09-07 19:47   ` Horatiu Vultur [this message]
2022-09-08  8:46 ` Linus Walleij
2022-09-08 21:22   ` Horatiu Vultur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220907194754.nw4jpghsjzuz2jcu@soft-dev3-1.localhost \
    --to=horatiu.vultur@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®