diff options
| author | Aleksandr Mishin <[email protected]> | 2024-06-18 14:43:44 +0000 |
|---|---|---|
| committer | Bartosz Golaszewski <[email protected]> | 2024-06-24 11:24:59 +0000 |
| commit | 7aa9b96e9a73e4ec1771492d0527bd5fc5ef9164 (patch) | |
| tree | 34bed1b2cfa9b44d10b9b6948731eef6c49110b7 /drivers/gpio/gpio-davinci.c | |
| parent | gpio: pca953x: fix pca953x_irq_bus_sync_unlock race (diff) | |
| download | kernel-7aa9b96e9a73e4ec1771492d0527bd5fc5ef9164.tar.gz kernel-7aa9b96e9a73e4ec1771492d0527bd5fc5ef9164.zip | |
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: eb3744a2dd01 ("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]>
Diffstat (limited to 'drivers/gpio/gpio-davinci.c')
| -rw-r--r-- | drivers/gpio/gpio-davinci.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index bb499e362912..1d0175d6350b 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -225,6 +225,11 @@ static int davinci_gpio_probe(struct platform_device *pdev) else nirq = DIV_ROUND_UP(ngpio, 16); + if (nirq > MAX_INT_PER_BANK) { + dev_err(dev, "Too many IRQs!\n"); + return -EINVAL; + } + chips = devm_kzalloc(dev, sizeof(*chips), GFP_KERNEL); if (!chips) return -ENOMEM; |
