Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4474062pxt; Wed, 11 Aug 2021 06:57:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCixrU+BCu5dsxbZdqz6p6MTc+nIp7pay9ISh0YPzKfcMwo1FJRUnydBnau44SPzqvvM7a X-Received: by 2002:a17:906:eb53:: with SMTP id mc19mr1088392ejb.22.1628690272353; Wed, 11 Aug 2021 06:57:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628690272; cv=none; d=google.com; s=arc-20160816; b=tnBA/vdwBBcYnToQaqWQp6aD7PwgS81a+kgwkxmrzyAMgcZfqM6V79lHjCgFgMwB78 oOMWy8aXCfCzf5Ama3/mn7Rtt+t0W9ARCkgDDHOLOsQ7Yw82oYkq8vdQ6q8KLNqD1YLD qgWTOk6rEp1SvbkQ7IxgHCclhGcAu11tqOQ6v6rmCj3YMmoUOXamUjGPcFpIs0201E4C u8SAefwGwLMtRD4t0nw7s31T4pR/m+bBkZl8e1GJzXPbNwN0NV5nbdhzUjtUymhGcaMv WLNVUyGBYuxvfzgVCsf69aTX5poAFjwNSKbaccZJWFlzlwj2bRyAEtWNVhaqHCC5npEx DKmQ== 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=LMv0/Ii3B+sj7gKmpj2+/Hi2I3L6dY7ZxJv5yw/qNhOxCiVAWdc6Scm3yB87KS4YA8 43bJ2Kqjg2oOGl63UI/eEVKCUAWGze/pUPWryO79sCk/YHNbeL3hBm8/BPe+UeGeoUt4 oAUH0upYRixgsih2JV0TC6AHL44l3TqaIKNrMD27t0Jih26GOa5i7JLKoBB7JBk+/+eP vp4dUolFhUr6Imw74k6xhUpIsDTopiPxlgE/2z4NSYpIqmUszMSBGjXwkuYdjZ96nqv1 GbbI6bqHFtcYfRhmyzjDrlQJZXpiIKgr3wU47Sl4FvrDcPz/c3AYTLYH7QvBymgsu3j9 OIJg== 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 s5si10667172edy.388.2021.08.11.06.57.27; Wed, 11 Aug 2021 06:57:52 -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 S231902AbhHKNyD (ORCPT + 99 others); Wed, 11 Aug 2021 09:54:03 -0400 Received: from mail.ispras.ru ([83.149.199.84]:41814 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231769AbhHKNyC (ORCPT ); Wed, 11 Aug 2021 09:54:02 -0400 Received: from kleverstation.intra.ispras.ru (unknown [10.10.2.220]) by mail.ispras.ru (Postfix) with ESMTPS id 0096940755FE; Wed, 11 Aug 2021 13:53:37 +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: Change function call order in dsps_probe() Date: Wed, 11 Aug 2021 16:53:31 +0300 Message-Id: <20210811135331.11808-1-lutovinova@ispras.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210811132927.10194-1-lutovinova@ispras.ru> 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