linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Dan Callaghan <dan.callaghan@opengear.com>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RESEND] gpiolib: hold gpio devices lock until ->descs array is initialised
Date: Thu, 23 Jan 2020 16:26:11 +0100	[thread overview]
Message-ID: <CACRpkdYGED-YU8PGUFwK-Arrs0Vp1=Oc-Nx=MvjuygLJvzQPkg@mail.gmail.com> (raw)
In-Reply-To: <20200121001216.15964-1-dan.callaghan@opengear.com>

On Tue, Jan 21, 2020 at 1:13 AM Dan Callaghan
<dan.callaghan@opengear.com> wrote:

> If a driver consuming the GPIO chip is being probed at the same time as
> the GPIO driver is registering the chip, it is possible for the
> consuming driver to see the ->descs array in an uninitialised state.
> For example, the gpio-keys-polled driver can fail like this:
>
>     kernel: gpiod_request: invalid GPIO (no device)
>     kernel: gpio-keys-polled PRP0001:07: failed to get gpio: -22
>     kernel: gpio-keys-polled: probe of PRP0001:07 failed with error -22
>
> This patch makes gpiochip_add() hold the lock protecting gpio_devices
> until it has finished setting desc->gdev on the newly inserted list
> entry.
>
> Signed-off-by: Dan Callaghan <dan.callaghan@opengear.com>
> ---
> Resending this one because I failed to cc the maintainers on the
> original posting, sorry about that.

This makes a lot of sense, I'm impressed that you managed to
provoke this error!

Patch applied.

Yours,
Linus Walleij

      reply	other threads:[~2020-01-23 15:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-21  0:12 [PATCH RESEND] gpiolib: hold gpio devices lock until ->descs array is initialised Dan Callaghan
2020-01-23 15:26 ` Linus Walleij [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='CACRpkdYGED-YU8PGUFwK-Arrs0Vp1=Oc-Nx=MvjuygLJvzQPkg@mail.gmail.com' \
    --to=linus.walleij@linaro.org \
    --cc=bgolaszewski@baylibre.com \
    --cc=dan.callaghan@opengear.com \
    --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;
as well as URLs for NNTP newsgroup(s).