This is a note to let you know that I've just added the patch titled gpio: davinci: Allocate the correct amount of memory for controller to the 4.19-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: gpio-davinci-allocate-the-correct-amount-of-memory-f.patch and it can be found in the queue-4.19 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit b0ad83162efdc95b7465f188464ac62f4c769707 Author: Andrew F. Davis <afd@xxxxxx> Date: Fri Aug 31 14:13:24 2018 -0500 gpio: davinci: Allocate the correct amount of memory for controller [ Upstream commit c809e37a3b5a889063ae737ff8b54705219d1ddc ] Previously we created a controller structure per bank of GPIO pins. This has since been changed to one per controller, but the allocation size was not changed. Fix this here. This also leaves the variable 'nbank' unused, instead of removing it, move it down and use it to clean up a loop. For loops with multiple initializers and/or iteration expressions, especially ones that don't use those loop counters are quite hard to follow, fix this. Signed-off-by: Andrew F. Davis <afd@xxxxxx> Tested-by: Keerthy <j-keerthy@xxxxxx> Acked-by: Keerthy <j-keerthy@xxxxxx> Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx> Stable-dep-of: 7aa9b96e9a73 ("gpio: davinci: Validate the obtained number of IRQs") Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index c94890466fe9c..a807a84948b70 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -165,7 +165,7 @@ davinci_gpio_get_pdata(struct platform_device *pdev) static int davinci_gpio_probe(struct platform_device *pdev) { - int gpio, bank, i, ret = 0; + int bank, i, ret = 0; unsigned int ngpio, nbank, nirq; struct davinci_gpio_controller *chips; struct davinci_gpio_platform_data *pdata; @@ -204,10 +204,7 @@ static int davinci_gpio_probe(struct platform_device *pdev) else nirq = DIV_ROUND_UP(ngpio, 16); - nbank = DIV_ROUND_UP(ngpio, 32); - chips = devm_kcalloc(dev, - nbank, sizeof(struct davinci_gpio_controller), - GFP_KERNEL); + chips = devm_kzalloc(dev, sizeof(*chips), GFP_KERNEL); if (!chips) return -ENOMEM; @@ -248,7 +245,8 @@ static int davinci_gpio_probe(struct platform_device *pdev) #endif spin_lock_init(&chips->lock); - for (gpio = 0, bank = 0; gpio < ngpio; gpio += 32, bank++) + nbank = DIV_ROUND_UP(ngpio, 32); + for (bank = 0; bank < nbank; bank++) chips->regs[bank] = gpio_base + offset_array[bank]; ret = devm_gpiochip_add_data(dev, &chips->chip, chips);