Re: [PATCH RESEND] gpiolib: hold gpio devices lock until ->descs array is initialised

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

 



On Tue, Jan 21, 2020 at 1:13 AM Dan Callaghan
<dan.callaghan@xxxxxxxxxxxx> 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@xxxxxxxxxxxx>
> ---
> 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



[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