[Xenomai] [PATCH] [PATCH] drivers/gpio: Fix of-by-one error in create_pin_devices().
Philippe Gerum
rpm at xenomai.org
Thu Oct 19 12:57:22 CEST 2017
On 10/19/2017 12:27 PM, Christoph Muellner wrote:
> create_pin_devices() consists of a loop, which creates a device file
> for each GPIO of a GPIO chip. The loop's run condition is too strong,
> which results in the last GPIO file not being created (e.g. gpio31 is
> missing in case gc->ngpio is 32 and gc->base is 0).
>
> This patch addresses this issue in branch 'next'.
>
> Tested on a RK3399 (arm64).
>
> Signed-off-by: Christoph Muellner <christoph.muellner at theobroma-systems.com>
> ---
> kernel/drivers/gpio/gpio-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
> index 5ffe41ff3..55594f6ae 100644
> --- a/kernel/drivers/gpio/gpio-core.c
> +++ b/kernel/drivers/gpio/gpio-core.c
> @@ -285,7 +285,7 @@ static int create_pin_devices(struct rtdm_gpio_chip *rgc)
> rtdm_lockctx_t s;
> int n, ret;
>
> - for (n = gc->base; n < gc->base + gc->ngpio - 1; n++) {
> + for (n = gc->base; n < gc->base + gc->ngpio; n++) {
> ret = -ENOMEM;
> pin = kzalloc(sizeof(*pin), GFP_KERNEL);
> if (pin == NULL)
>
Ack. Merged, thanks.
--
Philippe.
More information about the Xenomai
mailing list