summaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorAnton Vasilyev <vasilyev@ispras.ru>2018-07-23 19:53:30 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-26 08:33:54 +0200
commitd8596403ebd873c7c47229939a423f8d431a96be (patch)
tree8cd5eee8091d87cd8648088277a0defe51f3d8c2 /drivers/gpio
parent04924815bdc2a86e2a94b254397744712187352e (diff)
downloadlinux-stable-d8596403ebd873c7c47229939a423f8d431a96be.tar.gz
linux-stable-d8596403ebd873c7c47229939a423f8d431a96be.tar.bz2
linux-stable-d8596403ebd873c7c47229939a423f8d431a96be.zip
gpio: ml-ioh: Fix buffer underwrite on probe error path
[ Upstream commit 4bf4eed44bfe288f459496eaf38089502ef91a79 ] If ioh_gpio_probe() fails on devm_irq_alloc_descs() then chip may point to any element of chip_save array, so reverse iteration from pointer chip may become chip_save[-1] and gpiochip_remove() will operate with wrong memory. The patch fix the error path of ioh_gpio_probe() to correctly bypass chip_save array. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-ml-ioh.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c
index 5536108aa9db..fe21734bbe5c 100644
--- a/drivers/gpio/gpio-ml-ioh.c
+++ b/drivers/gpio/gpio-ml-ioh.c
@@ -495,9 +495,10 @@ err_irq_alloc_descs:
chip = chip_save;
err_gpiochip_add:
+ chip = chip_save;
while (--i >= 0) {
- chip--;
gpiochip_remove(&chip->gpio);
+ chip++;
}
kfree(chip_save);