linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Nadezda Lutovinova <lutovinova@ispras.ru>,
	Fabio Estevam <festevam@gmail.com>,
	Felipe Balbi <balbi@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH AUTOSEL 5.14 216/252] usb: dwc3: imx8mp: request irq after initializing dwc3
Date: Thu,  9 Sep 2021 07:40:30 -0400	[thread overview]
Message-ID: <20210909114106.141462-216-sashal@kernel.org> (raw)
In-Reply-To: <20210909114106.141462-1-sashal@kernel.org>

From: Nadezda Lutovinova <lutovinova@ispras.ru>

[ Upstream commit 6a48d0ae01a6ab05ae5e78328546a2f5f6d3054a ]

If IRQ occurs between calling  devm_request_threaded_irq() and
initializing dwc3_imx->dwc3, then null pointer dereference occurs
since dwc3_imx->dwc3 is used in dwc3_imx8mp_interrupt().

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

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

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Acked-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Nadezda Lutovinova <lutovinova@ispras.ru>
Link: https://lore.kernel.org/r/20210819154818.18334-1-lutovinova@ispras.ru
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/usb/dwc3/dwc3-imx8mp.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
index 756faa46d33a..d328d20abfbc 100644
--- a/drivers/usb/dwc3/dwc3-imx8mp.c
+++ b/drivers/usb/dwc3/dwc3-imx8mp.c
@@ -152,13 +152,6 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
 	}
 	dwc3_imx->irq = irq;
 
-	err = devm_request_threaded_irq(dev, irq, NULL, dwc3_imx8mp_interrupt,
-					IRQF_ONESHOT, dev_name(dev), dwc3_imx);
-	if (err) {
-		dev_err(dev, "failed to request IRQ #%d --> %d\n", irq, err);
-		goto disable_clks;
-	}
-
 	pm_runtime_set_active(dev);
 	pm_runtime_enable(dev);
 	err = pm_runtime_get_sync(dev);
@@ -186,6 +179,13 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
 	}
 	of_node_put(dwc3_np);
 
+	err = devm_request_threaded_irq(dev, irq, NULL, dwc3_imx8mp_interrupt,
+					IRQF_ONESHOT, dev_name(dev), dwc3_imx);
+	if (err) {
+		dev_err(dev, "failed to request IRQ #%d --> %d\n", irq, err);
+		goto depopulate;
+	}
+
 	device_set_wakeup_capable(dev, true);
 	pm_runtime_put(dev);
 
-- 
2.30.2


  parent reply	other threads:[~2021-09-09 12:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210909114106.141462-1-sashal@kernel.org>
2021-09-09 11:37 ` [PATCH AUTOSEL 5.14 039/252] usb: host: fotg210: fix the endpoint's transactional opportunities calculation Sasha Levin
2021-09-09 11:37 ` [PATCH AUTOSEL 5.14 040/252] usb: host: fotg210: fix the actual_length of an iso packet Sasha Levin
2021-09-09 11:37 ` [PATCH AUTOSEL 5.14 041/252] usb: gadget: u_ether: fix a potential null pointer dereference Sasha Levin
2021-09-09 11:37 ` [PATCH AUTOSEL 5.14 042/252] USB: EHCI: ehci-mv: improve error handling in mv_ehci_enable() Sasha Levin
2021-09-09 11:37 ` [PATCH AUTOSEL 5.14 043/252] usb: gadget: composite: Allow bMaxPower=0 if self-powered Sasha Levin
2021-09-09 11:39 ` [PATCH AUTOSEL 5.14 134/252] thunderbolt: Fix port linking by checking all adapters Sasha Levin
2021-09-09 11:39 ` [PATCH AUTOSEL 5.14 181/252] usb: chipidea: host: fix port index underflow and UBSAN complains Sasha Levin
2021-09-09 11:40 ` [PATCH AUTOSEL 5.14 215/252] Revert "USB: xhci: fix U1/U2 handling for hardware with XHCI_INTEL_HOST quirk set" Sasha Levin
2021-09-09 11:40 ` Sasha Levin [this message]
2021-09-09 11:40 ` [PATCH AUTOSEL 5.14 217/252] usb: musb: musb_dsps: request_irq() after initializing musb Sasha Levin
2021-09-09 11:40 ` [PATCH AUTOSEL 5.14 218/252] usbip: give back URBs for unsent unlink requests during cleanup Sasha Levin
2021-09-09 11:40 ` [PATCH AUTOSEL 5.14 219/252] usbip:vhci_hcd USB port can get stuck in the disabled state Sasha Levin
2021-09-09 11:40 ` [PATCH AUTOSEL 5.14 220/252] usb: xhci-mtk: fix use-after-free of mtk->hcd Sasha Levin
2021-09-09 11:40 ` [PATCH AUTOSEL 5.14 221/252] usb: xhci-mtk: Do not use xhci's virt_dev in drop_endpoint Sasha Levin
2021-09-09 11:40 ` [PATCH AUTOSEL 5.14 239/252] usb: isp1760: fix memory pool initialization Sasha Levin
2021-09-09 11:40 ` [PATCH AUTOSEL 5.14 240/252] usb: isp1760: fix qtd fill length Sasha Levin
2021-09-09 11:40 ` [PATCH AUTOSEL 5.14 241/252] usb: isp1760: write to status and address register Sasha Levin
2021-09-09 11:40 ` [PATCH AUTOSEL 5.14 242/252] usb: isp1760: use the right irq status bit Sasha Levin
2021-09-09 11:40 ` [PATCH AUTOSEL 5.14 243/252] usb: isp1760: otg control register access Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210909114106.141462-216-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=balbi@kernel.org \
    --cc=festevam@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lutovinova@ispras.ru \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).