LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] input: cpcap-pwrbutton: Add an error handling
@ 2021-08-02 12:17 Tang Bin
  2021-09-06  2:07 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Tang Bin @ 2021-08-02 12:17 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input, linux-kernel, Tang Bin

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 <tangbin@cmss.chinamobile.com>
---
 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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] input: cpcap-pwrbutton: Add an error handling
  2021-08-02 12:17 [PATCH] input: cpcap-pwrbutton: Add an error handling Tang Bin
@ 2021-09-06  2:07 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2021-09-06  2:07 UTC (permalink / raw)
  To: Tang Bin; +Cc: linux-input, linux-kernel

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.

> 
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-06  2:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-02 12:17 [PATCH] input: cpcap-pwrbutton: Add an error handling Tang Bin
2021-09-06  2:07 ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).