]> git.baikalelectronics.ru Git - kernel.git/commitdiff
Input: cpcap-pwrbutton - handle errors from platform_get_irq()
authorTang Bin <tangbin@cmss.chinamobile.com>
Mon, 6 Sep 2021 01:57:32 +0000 (18:57 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 6 Sep 2021 02:42:42 +0000 (19:42 -0700)
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>
Link: https://lore.kernel.org/r/20210802121740.8700-1-tangbin@cmss.chinamobile.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/misc/cpcap-pwrbutton.c

index 0abef63217e21ec3d687f38965223ec64c7c9070..372cb44d06357abcc15f92707ab4517e83bfda0d 100644 (file)
@@ -54,9 +54,13 @@ static irqreturn_t powerbutton_irq(int irq, void *_button)
 static int cpcap_power_button_probe(struct platform_device *pdev)
 {
        struct cpcap_power_button *button;
-       int irq = platform_get_irq(pdev, 0);
+       int irq;
        int err;
 
+       irq = platform_get_irq(pdev, 0);
+       if (irq < 0)
+               return irq;
+
        button = devm_kmalloc(&pdev->dev, sizeof(*button), GFP_KERNEL);
        if (!button)
                return -ENOMEM;