2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-25 13:43:55 +08:00

gpio: ep93xx: fix incorrect array element size check

Currently the while loop checks for the end of the array using
the size of egp->gc rather that the number of elements in the array,
so fix this. Also, perform the array size check first as stylistically
it is always good to bounds check on an array first before referencing
the array (in this case, we're just computing the address of an
element in an array so this is a moot point).

Fixes: fd935fc421 ("gpio: ep93xx: Do not pingpong irq numbers")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Colin Ian King 2018-09-06 12:58:30 +01:00 committed by Linus Walleij
parent 02ad0437de
commit f40f73075c

View File

@ -76,7 +76,7 @@ static int ep93xx_gpio_port(struct gpio_chip *gc)
struct ep93xx_gpio *epg = gpiochip_get_data(gc);
int port = 0;
while (gc != &epg->gc[port] && port < sizeof(epg->gc))
while (port < ARRAY_SIZE(epg->gc) && gc != &epg->gc[port])
port++;
/* This should not happen but is there as a last safeguard */