From: Anton Vasilyev Date: Mon, 23 Jul 2018 16:53:30 +0000 (+0300) Subject: gpio: ml-ioh: Fix buffer underwrite on probe error path X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=4bf4eed44bfe288f459496eaf38089502ef91a79;p=linux.git gpio: ml-ioh: Fix buffer underwrite on probe error path 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 Signed-off-by: Linus Walleij --- diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c index b23d9a36be1f4..51c7d1b84c2e8 100644 --- a/drivers/gpio/gpio-ml-ioh.c +++ b/drivers/gpio/gpio-ml-ioh.c @@ -496,9 +496,10 @@ static int ioh_gpio_probe(struct pci_dev *pdev, return 0; err_gpiochip_add: + chip = chip_save; while (--i >= 0) { - chip--; gpiochip_remove(&chip->gpio); + chip++; } kfree(chip_save);