Skip to content

Commit dde1881

Browse files
Aleksandr Mishinroxanan1996
authored andcommitted
gpio: davinci: Validate the obtained number of IRQs
BugLink: https://bugs.launchpad.net/bugs/2073765 [ Upstream commit 7aa9b96e9a73e4ec1771492d0527bd5fc5ef9164 ] 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 <amishin@t-argos.ru> Link: https://lore.kernel.org/r/20240618144344.16943-1-amishin@t-argos.ru Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Portia Stephens <portia.stephens@canonical.com> Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
1 parent c53362d commit dde1881

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)