[PATCH] input: cpcap-pwrbutton: Add an error handling

Subsystems: input (keyboard, mouse, joystick, touchscreen) drivers, the rest

STALE1865d LANDED

Landed in mainline as 58ae4004b9c4 on 2021-09-06.

2 messages, 2 authors, 2021-09-06 · open the first message on its own page

[PATCH] input: cpcap-pwrbutton: Add an error handling

From: Tang Bin <hidden>
Date: 2021-08-02 12:17:17

The function cpcap_power_button_probe() does not perform
sufficient error checking after executing platform_get_irq(),
thus fix it.

Signed-off-by: Tang Bin <redacted>
---
 drivers/input/misc/cpcap-pwrbutton.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/input/misc/cpcap-pwrbutton.c b/drivers/input/misc/cpcap-pwrbutton.c
index 0abef6321..0a1f2e8b4 100644
--- a/drivers/input/misc/cpcap-pwrbutton.c
+++ b/drivers/input/misc/cpcap-pwrbutton.c
@@ -57,6 +57,9 @@ static int cpcap_power_button_probe(struct platform_device *pdev)
 	int irq = platform_get_irq(pdev, 0);
 	int err;
 
+	if (irq < 0)
+		return irq;
+
 	button = devm_kmalloc(&pdev->dev, sizeof(*button), GFP_KERNEL);
 	if (!button)
 		return -ENOMEM;
-- 
2.20.1.windows.1


Re: [PATCH] input: cpcap-pwrbutton: Add an error handling

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: 2021-09-06 02:07:09

Hi,

On Mon, Aug 02, 2021 at 08:17:40PM +0800, Tang Bin wrote:
The function cpcap_power_button_probe() does not perform
sufficient error checking after executing platform_get_irq(),
thus fix it.
Yes, indeed. request_irq will fail regardless, but it is nice to return
proper error code.
quoted hunk
Signed-off-by: Tang Bin <redacted>
---
 drivers/input/misc/cpcap-pwrbutton.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/input/misc/cpcap-pwrbutton.c b/drivers/input/misc/cpcap-pwrbutton.c
index 0abef6321..0a1f2e8b4 100644
--- a/drivers/input/misc/cpcap-pwrbutton.c
+++ b/drivers/input/misc/cpcap-pwrbutton.c
@@ -57,6 +57,9 @@ static int cpcap_power_button_probe(struct platform_device *pdev)
 	int irq = platform_get_irq(pdev, 0);
 	int err;
 
+	if (irq < 0)
+		return irq;
I moved the platform_get_irq() here and applied, thank you.

-- 
Dmitry
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help