Skip to content

Commit 7aa9b96

Browse files
Aleksandr MishinBartosz Golaszewski
authored andcommitted
gpio: davinci: Validate the obtained number of IRQs
Value of pdata->gpio_unbanked is taken from Device Tree. In case of broken DT due to any error this value can be any. Without this value validation there can be out of chips->irqs array boundaries access in davinci_gpio_probe(). Validate the obtained nirq value so that it won't exceed the maximum number of IRQs per bank. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: eb3744a ("gpio: davinci: Do not assume continuous IRQ numbering") Signed-off-by: Aleksandr Mishin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent bfc6444 commit 7aa9b96

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/gpio/gpio-davinci.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ static int davinci_gpio_probe(struct platform_device *pdev)
225225
else
226226
nirq = DIV_ROUND_UP(ngpio, 16);
227227

228+
if (nirq > MAX_INT_PER_BANK) {
229+
dev_err(dev, "Too many IRQs!\n");
230+
return -EINVAL;
231+
}
232+
228233
chips = devm_kzalloc(dev, sizeof(*chips), GFP_KERNEL);
229234
if (!chips)
230235
return -ENOMEM;

0 commit comments

Comments
 (0)