Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5898eb79 authored by Axel Lin's avatar Axel Lin Committed by Eric Miao
Browse files

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: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarEric Miao <eric.y.miao@gmail.com>
parent 8aad172e
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -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;
}