Skip to content

Commit

Permalink
gpio: ml-ioh: Fix buffer underwrite on probe error path
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Anton Vasilyev authored and Linus Walleij committed Jul 29, 2018
1 parent 1777fc9 commit 4bf4eed
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/gpio/gpio-ml-ioh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 4bf4eed

Please sign in to comment.