[Xenomai] [PATCH] [PATCH] drivers/gpio: Fix of-by-one error in create_pin_devices().

Christoph Muellner christoph.muellner at theobroma-systems.com
Thu Oct 19 12:27:55 CEST 2017


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)
-- 
2.11.0




More information about the Xenomai mailing list