Re: Bug introduced in the of_get_named_gpiod_flags function.

From: Randy Dunlap
Date: Wed Oct 10 2018 - 12:39:36 EST


[adding linux-gpio + Linus W.]

On 10/10/18 9:13 AM, wzab wrote:
> Hi,
>
> The function of_get_named_gpiod_flags in older versions of the kernel
> (up to 4.7.10 - https://elixir.bootlin.com/linux/v4.7.10/source/drivers/gpio/gpiolib-of.c#L75 )
> contained an important workaround:
>
> /* .of_xlate might decide to not fill in the flags, so clear it. */if (flags)
> *flags = 0; Unfortunately, newer kernels do not contain it. Therefore if the
> "xlat" function in the gpiochip driver does not set flags, (like e.g.
> the Xilinx AXI GPIO driver: https://github.com/Xilinx/linux-xlnx/blob/c2ba891326bb472da59b6a2da29aca218d337687/drivers/gpio/gpio-xilinx.c#L262 )
> the random, unitialized value from the stack in of_find_gpio
> ( https://elixir.bootlin.com/linux/v4.18.13/source/drivers/gpio/gpiolib-of.c#L228 )
> is used, which results in random settings of e.g., OPEN DRAIN or OPEN SOURCE mode.
>
> I have also reported the problem in the Xilinx forum: https://forums.xilinx.com/t5/Embedded-Linux/Bug-in-of-get-named-gpiod-flags-function-in-the-kernel-random/td-p/897695
>
> With best regards,
> Wojciech Zabolotny
>
>
>


--
~Randy