diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 374bb9f432660b1ddb51c215353e4892810fa5f8..a8e63d8f0e3655b4b3261ee50fd2a2f6d0e9727d 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -143,7 +144,7 @@ struct gpio_desc *gpiochip_get_desc(struct gpio_chip *gc, if (hwnum >= gdev->ngpio) return ERR_PTR(-EINVAL); - return &gdev->descs[hwnum]; + return &gdev->descs[array_index_nospec(hwnum, gdev->ngpio)]; } EXPORT_SYMBOL_GPL(gpiochip_get_desc);