Skip to content

Commit 70b4889

Browse files
Aleksandr Mishingregkh
Aleksandr Mishin
authored andcommitted
gpio: davinci: Validate the obtained number of IRQs
[ Upstream commit 7aa9b96 ] 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 287ea87 commit 70b4889

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
@@ -227,6 +227,11 @@ static int davinci_gpio_probe(struct platform_device *pdev)
227227
else
228228
nirq = DIV_ROUND_UP(ngpio, 16);
229229

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

0 commit comments

Comments
 (0)