diff mbox series

Input: omap4-keypad: fix ref count leak if pm_runtime_get_sync fails

Message ID 20200614055208.86350-1-navid.emamdoost@gmail.com
State New
Headers show
Series Input: omap4-keypad: fix ref count leak if pm_runtime_get_sync fails | expand

Commit Message

Navid Emamdoost June 14, 2020, 5:52 a.m. UTC
calling pm_runtime_get_sync increments the counter even in case of
failure, leading to incorrect ref count. In case of failure, decrement
the ref count before returning.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/input/keyboard/omap4-keypad.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index 94c94d7f5155..35ac788d9fa0 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -280,7 +280,7 @@  static int omap4_keypad_probe(struct platform_device *pdev)
 	error = pm_runtime_get_sync(&pdev->dev);
 	if (error) {
 		dev_err(&pdev->dev, "pm_runtime_get_sync() failed\n");
-		goto err_unmap;
+		goto err_pm_put_sync;
 	}
 	rev = __raw_readl(keypad_data->base + OMAP4_KBD_REVISION);
 	rev &= 0x03 << 30;
@@ -372,7 +372,6 @@  static int omap4_keypad_probe(struct platform_device *pdev)
 	input_free_device(input_dev);
 err_pm_put_sync:
 	pm_runtime_put_sync(&pdev->dev);
-err_unmap:
 	iounmap(keypad_data->base);
 err_release_mem:
 	release_mem_region(res->start, resource_size(res));