diff options
-rw-r--r-- | drivers/gpio/gpiolib.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 4e10b10d3ddd..c6326e44e2c0 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -150,9 +150,10 @@ EXPORT_SYMBOL_GPL(gpio_to_desc); | |||
150 | static struct gpio_desc *gpiochip_offset_to_desc(struct gpio_chip *chip, | 150 | static struct gpio_desc *gpiochip_offset_to_desc(struct gpio_chip *chip, |
151 | unsigned int offset) | 151 | unsigned int offset) |
152 | { | 152 | { |
153 | unsigned int gpio = chip->base + offset; | 153 | if (offset >= chip->ngpio) |
154 | return ERR_PTR(-EINVAL); | ||
154 | 155 | ||
155 | return gpio_to_desc(gpio); | 156 | return &chip->desc[offset]; |
156 | } | 157 | } |
157 | 158 | ||
158 | /** | 159 | /** |