gpio: pm8xxx: Fix memory leak in probe function
CRs-fixed: 313701
Change-Id: I2045966768fc1a3ef5c2656562df4032d6d1f857
Signed-off-by: Jay Chokshi <jchokshi@codeaurora.org>
diff --git a/drivers/gpio/pm8xxx-gpio.c b/drivers/gpio/pm8xxx-gpio.c
index 026fd05..377510f 100644
--- a/drivers/gpio/pm8xxx-gpio.c
+++ b/drivers/gpio/pm8xxx-gpio.c
@@ -289,7 +289,8 @@
GFP_KERNEL);
if (!pm_gpio_chip->bank1) {
pr_err("Cannot allocate pm_gpio_chip->bank1\n");
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto free_chip;
}
spin_lock_init(&pm_gpio_chip->pm_lock);
@@ -332,6 +333,8 @@
pr_err("failed to remove gpio chip\n");
reset_drvdata:
platform_set_drvdata(pdev, NULL);
+ kfree(pm_gpio_chip->bank1);
+free_chip:
kfree(pm_gpio_chip);
return ret;
}