]> git.baikalelectronics.ru Git - kernel.git/commitdiff
usb: musb: musb_dsps: request_irq() after initializing musb
authorNadezda Lutovinova <lutovinova@ispras.ru>
Thu, 19 Aug 2021 16:33:23 +0000 (19:33 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Sep 2021 10:26:35 +0000 (12:26 +0200)
[ Upstream commit 7c75bde329d7e2a93cf86a5c15c61f96f1446cdc ]

If IRQ occurs between calling  dsps_setup_optional_vbus_irq()
and  dsps_create_musb_pdev(), then null pointer dereference occurs
since glue->musb wasn't initialized yet.

The patch puts initializing of neccesery data before registration
of the interrupt handler.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Nadezda Lutovinova <lutovinova@ispras.ru>
Link: https://lore.kernel.org/r/20210819163323.17714-1-lutovinova@ispras.ru
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/musb/musb_dsps.c

index 327d4f7baaf7c17bace48f0ed4908e83b200fd56..89d659cef5c631d15811bf0bb0b45f5568a55cd5 100644 (file)
@@ -890,23 +890,22 @@ static int dsps_probe(struct platform_device *pdev)
        if (!glue->usbss_base)
                return -ENXIO;
 
-       if (usb_get_dr_mode(&pdev->dev) == USB_DR_MODE_PERIPHERAL) {
-               ret = dsps_setup_optional_vbus_irq(pdev, glue);
-               if (ret)
-                       goto err_iounmap;
-       }
-
        platform_set_drvdata(pdev, glue);
        pm_runtime_enable(&pdev->dev);
        ret = dsps_create_musb_pdev(glue, pdev);
        if (ret)
                goto err;
 
+       if (usb_get_dr_mode(&pdev->dev) == USB_DR_MODE_PERIPHERAL) {
+               ret = dsps_setup_optional_vbus_irq(pdev, glue);
+               if (ret)
+                       goto err;
+       }
+
        return 0;
 
 err:
        pm_runtime_disable(&pdev->dev);
-err_iounmap:
        iounmap(glue->usbss_base);
        return ret;
 }