All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Alexey Dobriyan <adobriyan@gmail.com>,
	stable@vger.kernel.org, Stefan Wahren <wahrenst@gmx.net>,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH v2] gpio: cdev: sanitize the label before requesting the interrupt
Date: Fri, 22 Mar 2024 19:57:54 +0800	[thread overview]
Message-ID: <20240322115754.GA45839@rigel> (raw)
In-Reply-To: <CAMRc=Md87eGmjehSEegdFCdv6D3H1p2On153JowY5cDnW9iw8Q@mail.gmail.com>

On Fri, Mar 22, 2024 at 12:52:29PM +0100, Bartosz Golaszewski wrote:
> On Fri, Mar 22, 2024 at 12:18 PM Kent Gibson <warthog618@gmail.com> wrote:
> >
> > On Fri, Mar 22, 2024 at 10:02:08AM +0100, Bartosz Golaszewski wrote:
> > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > >
> > > @@ -2198,12 +2216,18 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
> > >       if (ret)
> > >               goto out_free_le;
> > >
> > > +     label = make_irq_label(le->label);
> > > +     if (!label) {
> > > +             ret = -ENOMEM;
> > > +             goto out_free_le;
> > > +     }
> > > +
> > >       /* Request a thread to read the events */
> > >       ret = request_threaded_irq(irq,
> > >                                  lineevent_irq_handler,
> > >                                  lineevent_irq_thread,
> > >                                  irqflags,
> > > -                                le->label,
> > > +                                label,
> > >                                  le);
> > >       if (ret)
> > >               goto out_free_le;
> >
> > Leaks label if the request_threaded_irq() fails.
> >
>
> Ah, dammit, I didn't catch the fact that irq_free() will not return
> the label address if the request failed.
>

You caught it in edge_detector_setup() - you call free_irq_label() if
request_threaded_irq() fails there.

> Nice catch.

The give away here is that the goto targets are the same.
Bit irritated that I didn't catch it earlier - got distracted by the
return code problem.

Anyway, third time lucky.

Cheers,
Kent.

      reply	other threads:[~2024-03-22 12:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22  9:02 [PATCH v2] gpio: cdev: sanitize the label before requesting the interrupt Bartosz Golaszewski
2024-03-22 11:18 ` Kent Gibson
2024-03-22 11:52   ` Bartosz Golaszewski
2024-03-22 11:57     ` Kent Gibson [this message]

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=20240322115754.GA45839@rigel \
    --to=warthog618@gmail.com \
    --cc=adobriyan@gmail.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=wahrenst@gmx.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.