Skip to content

Commit

Permalink
ARM: pxa/am300epd: fix leak in am300_init_gpio_regs error path
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Axel Lin authored and Eric Miao committed Mar 17, 2011
1 parent 8aad172 commit 5898eb7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions arch/arm/mach-pxa/am300epd.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ static int am300_init_gpio_regs(struct broadsheetfb_par *par)
if (err) {
dev_err(&am300_device->dev, "failed requesting "
"gpio %d, err=%d\n", i, err);
while (i >= DB0_GPIO_PIN)
gpio_free(i--);
i = ARRAY_SIZE(gpios) - 1;
goto err_req_gpio;
goto err_req_gpio2;
}
}

Expand Down Expand Up @@ -159,9 +156,13 @@ static int am300_init_gpio_regs(struct broadsheetfb_par *par)

return 0;

err_req_gpio2:
while (--i >= DB0_GPIO_PIN)
gpio_free(i);
i = ARRAY_SIZE(gpios);
err_req_gpio:
while (i > 0)
gpio_free(gpios[i--]);
while (--i >= 0)
gpio_free(gpios[i]);

return err;
}
Expand Down

0 comments on commit 5898eb7

Please sign in to comment.