Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp686581pxb; Thu, 19 Aug 2021 08:52:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpJKINy5B59b51Sj8+suttlyI9pzlbOhjCYCSXEV/W63sIXqknyzBm544fTsupchc/J9I+ X-Received: by 2002:a17:906:1fd5:: with SMTP id e21mr15992528ejt.78.1629388353614; Thu, 19 Aug 2021 08:52:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629388353; cv=none; d=google.com; s=arc-20160816; b=LR7JKbd+lqrC0Lt4dkQ2KYF1yZ+Va1+V/E8PIDpOmUvU2vnwH1jVORj/RFCsKFc2dt 9r952UlJ1X/ufgJ5IUH2FY8iAQ4fsPa0lcP3maEnm7vHDrTsYF0pfabjB7adOQrAoCry 7RswhHZCSRwXjKxD7Ao7tswpU4eVKOTvFHoXd0Je9gi30rs+5e05eUlDUGbaBHmSMOvf 3IuWhowdKw2uX6zzTHh+gUpxjH3hD6W4IxT/7x5NsrPQGm3HA+izrdBeH11SeD4mifnU M7AGlSJBQ+WqhWmw4cI/0gTJGMS9x8/CXjVsouMx8w/fDSp/TYgzqN2LapCipXrgFIhG jjMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=3fZcswP6vdlxwlp6RP7tnA3VnjaQcvE6lCr95ZOi+pk=; b=rkD9L7135UIe5c2p7T5Y7DNXeeDSP7BdAGp+eWgmuXSlIeQglbmt4cZ858CYti+ZFW YxIBAb7G95KZ+bVi7vOzpedSClcIXVnvx4zIY+ykaDqVcJFEJdM7GEoRGq3ZwuexgQ8Z 3jXfu+kcTxmO6sjxkqFfRjaX509icGamsAzW/kb20a9vyjGv4J45TUHjvnmF2apE98K0 8PA39CgH7YpDaK7DtLdBFvsaDPF85PyN2HPHnTO+GJxO9isoiUJ/MX4yxOBWA/YTTURB KVmc4/uWyOX/g8db3bDWTImiU4CCbv+D8iF0u8UgKaKhZ/5PRF5KrcNa6/YEdx2B62po PnrA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x23si3622383ejv.167.2021.08.19.08.52.09; Thu, 19 Aug 2021 08:52:33 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240639AbhHSPtY (ORCPT + 99 others); Thu, 19 Aug 2021 11:49:24 -0400 Received: from mail.ispras.ru ([83.149.199.84]:47046 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240674AbhHSPtU (ORCPT ); Thu, 19 Aug 2021 11:49:20 -0400 Received: from kleverstation.intra.ispras.ru (unknown [10.10.2.220]) by mail.ispras.ru (Postfix) with ESMTPS id 42C2E4076273; Thu, 19 Aug 2021 15:48:36 +0000 (UTC) From: Nadezda Lutovinova To: Felipe Balbi Cc: Nadezda Lutovinova , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] usb: dwc3: imx8mp: request irq after initializing dwc3 Date: Thu, 19 Aug 2021 18:48:18 +0300 Message-Id: <20210819154818.18334-1-lutovinova@ispras.ru> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). Signed-off-by: Nadezda Lutovinova --- 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.17.1