am200epd: fix resource leak in am200_init_gpio_regs error path
Subsystems (3)
PATCH 1/2 am200epd: fix resource leak in am200_init_gpio_regs error path
If gpio_request fails when i > 0, gpios[0] is not freed in current implementation.
--- arch/arm/mach-pxa/am200epd.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-pxa/am200epd.c +2 -2
@@ -128,8 +128,8 @@ static int am200_init_gpio_regs(struct metronomefb_par *par)return 0 ; err_req_gpio: -while (i >0 ) -gpio_free (gpios[i--]); +while (--i >=0 ) +gpio_free (gpios[i]);return err; }
Signature · 1 line
1.7.2
PATCH 2/2 am300epd: fix resource leak in am300_init_gpio_regs error path
If gpio_request fails when i > 0, gpios[0] is not freed in current implementation.
--- arch/arm/mach-pxa/am300epd.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
arch/arm/mach-pxa/am300epd.c +7 -6
@@ -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; } }
@@ -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; }
Signature · 1 line
1.7.2
Eric Miao
AppliedRe: [PATCH 2/2] [ARM] am300epd: fix resource leak in am300_init_gpio_regs error path
Applied.
Quoted 46 lines · Axel Lin
If
gpio_requestfails when i > 0, gpios[0] is not freed in current implementation.Signed-off-by Axel Lin <[email protected]>---
?arch/arm/mach-pxa/am300epd.c | ? 13 +++++++------ ?1 files changed, 7 insertions(+), 6 deletions(-)arch/arm/mach-pxa/am300epd.c +0
-0@@ -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;
- ? ? ? ? ? ? ? ? ? ? ? gotoerr_req_gpio;
+ ? ? ? ? ? ? ? ? ? ? ? gotoerr_req_gpio2;
? ? ? ? ? ? ? ?}
? ? ? ?}arch/arm/mach-pxa/am300epd.c +4
-0@@ -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;
?}
--
1.7.2
Eric Miao
AppliedApplied.
Quoted 29 lines · Axel Lin
If
gpio_requestfails when i > 0, gpios[0] is not freed in current implementation.Signed-off-by Axel Lin <[email protected]>---
?arch/arm/mach-pxa/am200epd.c | ? ?4 ++--
?1 files changed, 2 insertions(+), 2 deletions(-)arch/arm/mach-pxa/am200epd.c +0
-0@@ -128,8 +128,8 @@ static int am200_init_gpio_regs(struct metronomefb_par *par) ? ? ? ?return 0;?err_req_gpio:
- ? ? ? while (i > 0)
- ? ? ? ? ? ? ?gpio_free(gpios[i--]);
+ ? ? ? while (--i >= 0)
+ ? ? ? ? ? ? ?gpio_free(gpios[i]);? ? ? ?return err;
?}
--
1.7.2