Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp460013pxb; Thu, 9 Sep 2021 05:06:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6yfbGBDB8JE/R+eYf/aBpl7+DrUxd23K5TYHBgFRsNoTTGf/TL5gg68asvBDgyDP5myp1 X-Received: by 2002:aa7:db10:: with SMTP id t16mr2774943eds.357.1631189160760; Thu, 09 Sep 2021 05:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631189160; cv=none; d=google.com; s=arc-20160816; b=YrtgtM3rAetU8LUVuceAyKQk703K/zqPfjKEEj3R9tT6nyhXIcbFLA4Vsbs63WtRkU oUblvY5eL/MsCoM0pdNd0IVbt5xlpuJSeNyE2HcH2Fc77G4u9Wc0GgHvlQI9jcGdZdkn Nv/F2i4/nymFhHmhWMMCwtUq0eQ5bt3OBbcrIWFVhTy2ytHUwD5W6OUkAg0N47cCd6zF //gxMW8emYJrtsCAcSo3D4EpmpEaQ3o3QVQEJ8nSCkc6ujCMHfflhbnBw5n6mjetRde7 m5vYZi7lZyPvsqyb4H8lvUTXyVFVw5eY/7K5wP3fvo0FHfFvGKjv8MMqtf67oPrIcbH3 pGnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=c5O5MinDB+y0TfX82W+04ZZ2jNUtBKpFH6mlLCGwJoo=; b=BlcvWzUsWwXqIAif1vP8HKjz8WvzV5S+UPIEmnJE+iw9m9cb77MNaJHL71sjqDBPwl hBZRGAEUnl+eX+1Fn5tDb+RC47IgvtIYoqw358/nFNxaDJroknbXZQeR3mQ18hd3WAZu tN38UT5zlQOqWD4v6qRVE1u12mMvax0CJ/1SlXRP20i3QLSadN3GtsoipzRHSCvqMJJH +WOPGxNiCr8lq8n7RATxwKW2eUKUrU/58hDN00kaT+Lgpgb/Hg+2PtAd2KMSeq0bygsT Ymk86NkVknjGQp5lJcI7Lp3E52T2hGdrxp/Eairvgrwbax/Pz0ISwFeIVBa6nYXYVFad x0Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=azPGZSOr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz20si1711158ejb.263.2021.09.09.05.05.18; Thu, 09 Sep 2021 05:06:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=azPGZSOr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243087AbhIIMC5 (ORCPT + 99 others); Thu, 9 Sep 2021 08:02:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:34484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344163AbhIIL6n (ORCPT ); Thu, 9 Sep 2021 07:58:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9DA6B6140D; Thu, 9 Sep 2021 11:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187947; bh=vSCHNd0fBThLqXKbCXghXdPcsOfYDxh1LqWH4fhyoko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=azPGZSOre9fMmUJkmXOTrsGfN59XRXLxDypJRj73EG7PFrG9ey6hjMXepnd5PWfrt L0RrKUOtFLzCXHomdS9Rmg4sGaxyNzLOUXA8DzOx51dgkqkWEhup9UctRp2OIN06gS eFaY5oz90+Wiq//NdxHA44ur+SH8JqiKLHzYuKzKM/sPZnwkVzEC7LUdYwg52gM7LQ XAt6CxV1gcK76I8+x/+qsKczD53zJuUtgzQn8Dzc/C+2iTir3CTzU9bKS+tCtpPokX Z83h+QgFPb8g2psgUWnT+YCNk4aZkJF4oKhrZlwq3RtfkLN6HPETk5+3lRHo5gPEh5 DuoDsbeG1vZiA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nadezda Lutovinova , Fabio Estevam , Felipe Balbi , Greg Kroah-Hartman , Sasha Levin , 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 Message-Id: <20210909114106.141462-216-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nadezda Lutovinova [ 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 Acked-by: Felipe Balbi Signed-off-by: Nadezda Lutovinova Link: https://lore.kernel.org/r/20210819154818.18334-1-lutovinova@ispras.ru Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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