ARM: pxa/am300epd: fix leak in am300_init_gpio_regs error path

If gpio_request fails when i > 0, gpios[0] is not freed in current
implementation.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Eric Miao <eric.y.miao@gmail.com>
This commit is contained in:
Axel Lin 2011-03-07 13:56:11 +08:00 committed by Eric Miao
parent 8aad172e6c
commit 5898eb79fb

View File

@ -125,10 +125,7 @@ static int am300_init_gpio_regs(struct broadsheetfb_par *par)
if (err) { if (err) {
dev_err(&am300_device->dev, "failed requesting " dev_err(&am300_device->dev, "failed requesting "
"gpio %d, err=%d\n", i, err); "gpio %d, err=%d\n", i, err);
while (i >= DB0_GPIO_PIN) goto err_req_gpio2;
gpio_free(i--);
i = ARRAY_SIZE(gpios) - 1;
goto err_req_gpio;
} }
} }
@ -159,9 +156,13 @@ static int am300_init_gpio_regs(struct broadsheetfb_par *par)
return 0; return 0;
err_req_gpio2:
while (--i >= DB0_GPIO_PIN)
gpio_free(i);
i = ARRAY_SIZE(gpios);
err_req_gpio: err_req_gpio:
while (i > 0) while (--i >= 0)
gpio_free(gpios[i--]); gpio_free(gpios[i]);
return err; return err;
} }