diff mbox series

Input: ep93xx_keypad - Add check for clk_enable() and clk_prepare_enable

Message ID 20241111202006.6669-1-jiashengjiangcool@gmail.com
State New
Headers show
Series Input: ep93xx_keypad - Add check for clk_enable() and clk_prepare_enable | expand

Commit Message

Jiasheng Jiang Nov. 11, 2024, 8:20 p.m. UTC
Add check for the return value of clk_enable() and clk_prepare_enable()
in order to catch the potential exception.

Fixes: e06003af56c3 ("Input: add matrix keypad driver for Cirrus EP93xx")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
---
 drivers/input/keyboard/ep93xx_keypad.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
index dcbc50304a5a..06252694f2da 100644
--- a/drivers/input/keyboard/ep93xx_keypad.c
+++ b/drivers/input/keyboard/ep93xx_keypad.c
@@ -141,10 +141,14 @@  static void ep93xx_keypad_config(struct ep93xx_keypad *keypad)
 static int ep93xx_keypad_open(struct input_dev *pdev)
 {
 	struct ep93xx_keypad *keypad = input_get_drvdata(pdev);
+	int ret;
 
 	if (!keypad->enabled) {
 		ep93xx_keypad_config(keypad);
-		clk_prepare_enable(keypad->clk);
+		ret = clk_prepare_enable(keypad->clk);
+		if (ret)
+			return ret;
+
 		keypad->enabled = true;
 	}
 
@@ -185,13 +189,19 @@  static int ep93xx_keypad_resume(struct device *dev)
 	struct platform_device *pdev = to_platform_device(dev);
 	struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
 	struct input_dev *input_dev = keypad->input_dev;
+	int ret;
 
 	mutex_lock(&input_dev->mutex);
 
 	if (input_device_enabled(input_dev)) {
 		if (!keypad->enabled) {
 			ep93xx_keypad_config(keypad);
-			clk_enable(keypad->clk);
+			ret = clk_enable(keypad->clk);
+			if (ret) {
+				mutex_unlock(&input_dev->mutex);
+				return ret;
+			}
+
 			keypad->enabled = true;
 		}
 	}