Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp719697pxb; Thu, 19 Aug 2021 09:35:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWiMyCRmRjuzQSwfeJCjG65r+gKYk7Wxnu0CQyvlknf4F9XFJavY/R/2lEPOERrGYIQlk0 X-Received: by 2002:a05:6e02:1d06:: with SMTP id i6mr10482680ila.113.1629390946089; Thu, 19 Aug 2021 09:35:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629390946; cv=none; d=google.com; s=arc-20160816; b=dzhCtngiQtS3jGfCPdpzhx9rO7ucLpVMkrmGcl53zbIJYgdXPKYgbHQylmtVZ+cw4c KxlVS+TzVcMRxHk3ZeE9+uR6H0GGnbkC0Y+TuI4UyE17STMzVS2SJnzI5I3jsMHrnVUq LKN2FfQhx3VGq8eaG6PviOCUTyiwZhMiglWC4dbICd/YrIxao87qpaFG7Rd3jPMBF1k5 qB+mKN3C73nQDzb8wsVkekJM73w1MEK8i9fUuN9El5sPCaUEB0Uj3iC91F7knXtKXLo4 zbxHOiZGWhsiOT/LFlTHLqU50CAM6zVUfftKOwtue1TcuEUGIjtC5RoepsVhoS64Suir lsNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:message-id:date:subject:cc:to:from; bh=rPw/ghXVmGbFnPz1rk0AfMu1CzMErc5tzoXeJJenAX8=; b=ZQaIUhlnUnvZqTgOQtHFtkZCA/UgU6LLah8yMXVriX4f0DHkgJfugCmUu+0B+E07yU 770kHkt3eb2CwJoNGrPg3LJ9eWXKqj5YKJqpRf0cV63o+I3JuA62YZm1ZWQ7KBQBKgkb UHXOBMhIRvoRwMNXxXId0ajajrfW9HPp5JP6wbTajO4Xl/nA1ZtzNWD2bN0c+5lKvg/s EM9T/z4Jc40hRALaYEztXKsfNCLOEWIhBSml69NKKluLkWJJ7/WQLZoQXn0CPNocZIrF XC64avI5se3qvAivLrp4q5QBJ1IsoaCvoSv0lo2jE0nX/OYRNHa4vAOh5t/hxhiYlgu8 evNQ== 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 v16si3705213jas.2.2021.08.19.09.35.30; Thu, 19 Aug 2021 09:35:46 -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 S229606AbhHSQeF (ORCPT + 99 others); Thu, 19 Aug 2021 12:34:05 -0400 Received: from mail.ispras.ru ([83.149.199.84]:53522 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbhHSQeF (ORCPT ); Thu, 19 Aug 2021 12:34:05 -0400 Received: from kleverstation.intra.ispras.ru (unknown [10.10.2.220]) by mail.ispras.ru (Postfix) with ESMTPS id 8D8DA4076273; Thu, 19 Aug 2021 16:33:27 +0000 (UTC) From: Nadezda Lutovinova To: Bin Liu Cc: Nadezda Lutovinova , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH v2] usb: musb: musb_dsps: request_irq() after initializing musb Date: Thu, 19 Aug 2021 19:33:23 +0300 Message-Id: <20210819163323.17714-1-lutovinova@ispras.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- v2: fix subject --- drivers/usb/musb/musb_dsps.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 5892f3ce0cdc..ce9fc46c9266 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -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; } -- 2.17.1