Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4456812pxt; Wed, 11 Aug 2021 06:33:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybnlcGB0y8UoegLsj7v1HGntzqIkxx+JOQ1A5oelYjVgVXfaS8fUcreBIJX5TWwy1gCOXR X-Received: by 2002:a17:906:f15:: with SMTP id z21mr3685929eji.177.1628688833079; Wed, 11 Aug 2021 06:33:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628688833; cv=none; d=google.com; s=arc-20160816; b=MwMceMzQ9ibpOo0aE2CXVurmmq6UXmnWaKoTuBGHDxYf2lv6mpORXnum2AZBdYNWtD p+tpzEZSm4IMTNqhb8/kFeJ/01WhC6hKXfCFazydS9VpfE2voE4qCY8rqpZFwyKd2ZGE 8nTzilpU05yWVY2YeXvrMUl5FG3Cdkl/EqNDa5iyf0isStiDTES7neuzTDSUwijPL5LZ JljFKzH7uL52P715TIIfQ5hT6b4t122K1eRS9YN68dK5UduH7wcMTqOVaJs+a5l6vHWX w4eKES4rxmOfQ5kUfAJohYCF8QKbRce8QEFZQi5RKNxKTqwEBNMF7/uioI3dVH+rX86v Jb+A== 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=7mNnyD7ZpAT9KLQI4qhXJh5OKKGlhgKTcIcnCVYCCTw=; b=t6VXoigPk8YdvxKfGo7sodNXSQ8iBBLRfh6YxDJcpR3K7AFzQq4cssgKxLdZwI5syh 48WnzJabz+k8WDFYPmSdwfUtX6m/5djIS2fpeP+jFirkZi5uZmg0Sp9fxveg7SzdGgZ6 vM9nKIiimffhkkqNJ9/ai6BoNC/lK2QZ4HUPLUdDyK7mPasBzvUn5xVf72Sh20pLvJ3d 5pBWfliOGaFrX9b6Mm9AiF6Qc7QhfiYgj62XneZ5Srn6f0RcVS4G8zQJRzAuG2NmSL/k g0LJVLv8xW6/Z+kvFI1WBmLbrjX48oDdCXaW+nyKnLqzeF7Hx33MdTTcgGxWqvtbxa06 Qqnw== 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 c22si9114374ejb.187.2021.08.11.06.33.29; Wed, 11 Aug 2021 06:33:53 -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 S231514AbhHKNaR (ORCPT + 99 others); Wed, 11 Aug 2021 09:30:17 -0400 Received: from mail.ispras.ru ([83.149.199.84]:37734 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231477AbhHKNaO (ORCPT ); Wed, 11 Aug 2021 09:30:14 -0400 Received: from kleverstation.intra.ispras.ru (unknown [10.10.2.220]) by mail.ispras.ru (Postfix) with ESMTPS id 058A540A2BCD; Wed, 11 Aug 2021 13:29:41 +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: Date: Wed, 11 Aug 2021 16:29:27 +0300 Message-Id: <20210811132927.10194-1-lutovinova@ispras.ru> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Date: Fri, 30 Jul 2021 18:20:00 +0300 Subject: [PATCH] usb: musb: musb_dsps: Change function call order in dsps_probe() 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 --- 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