Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp460832pxb; Thu, 9 Sep 2021 05:06:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy75kUP+V+hFkz1rLafUaK4+7SSnBHBVjvGD9yPoeLCoobE3z+nuQM2/xbK8nuC8+ijyYfi X-Received: by 2002:a50:fb06:: with SMTP id d6mr1012279edq.31.1631189212833; Thu, 09 Sep 2021 05:06:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631189212; cv=none; d=google.com; s=arc-20160816; b=ql6sMcYFFrY5etiQ4vNar03NibR1jnCnsUP8RGlW5pJGDz6+8O7sgWXOJBXe1lUQGu 9eN7VPGjyWfpPBJp0EE5sgHwbGL8UDZ+89M74+TSMrN/Q5heUvlrREVEpitz/1LCILO3 ERfn77v5buBVFZL+J8nGH8bUmMl7G2mBj58qJHPilI8GqeiurdskjFrb7l9aAa0eS9U/ 4vPgmG+WGHoHYaa1ck76fN4v44iyjn+1M0RGADekvkb2z1wVOU1oMuazQkJJW9vTMjP2 Mo47LsaBlqIhs/A2cn/1zszLbu+Qw55WauKkchZwWAXBd1W+qBCFry1h1IKy6iBnv/Su yQdQ== 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=G+SEWTyGU8vzRhrcSP8W2iD8PydVDb4MqjhJjLXa+7k=; b=EmWidH7DOfzRP8VYj2LqMRkqHkPn5yUxCnASDB5RnXUTEouXhZEwuyqJTdY66MwwiU dOKQ2i95Fe9ZtAWJa/FD4aVGV7wPcfM76L/wGOU+QauivdBYCVF1Vg0NEXsQp2NrIiFU wQpZ6SxVpFeCaWB0Cf01oDBvrfPgU3RYKzZ/tuuALuM4ACq9T4Yy/N5/tPXZHXjOm1a+ Odc6dDcwAWr6in/Ij80VCVJWvSy8+y4VnG29PrHW/QyckoZXXVzpdOAezul/xjnbpjG3 HhEcgyPHTaTe4wISNENbN6BodNrY4Hytt6mHHtoAcimht8G8t5aaaa6HhJohGA3zAVjQ ABEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="eKZP/2wU"; 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 jy12si1478753ejc.167.2021.09.09.05.06.17; Thu, 09 Sep 2021 05:06: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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="eKZP/2wU"; 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 S1347048AbhIIMEN (ORCPT + 99 others); Thu, 9 Sep 2021 08:04:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:34520 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240211AbhIIL6o (ORCPT ); Thu, 9 Sep 2021 07:58:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0B21C611F0; Thu, 9 Sep 2021 11:45:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187948; bh=L+Zrw3R7HuZQRklNozrduxknMAPTxCggBqZfIcjfZ9Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eKZP/2wUIRMpRTm46ZB6MEySiJc8CXfP/fqd4jFp1SBqjAJUGnPwcVIMfA2OPf0Q0 mEM1ZGfQc7Be3XkSCnhVLLr+bVLvyvgVQCPY3aLiakFm1UITsbj+/fzCRJlBo3V/Sd YVBOkhW6fbYAfgZ625sFibe03TfwlK0p7Sr+k2/ufNuYpSZZRN0kFNsrxk/s0wsTdK bCDTuB9nl20jwxczFyZwS99eMqhCXCaqJNxkyTA99E6slvcT/rRkOYXmWIXHQCrcgP /uK0s0drb4clmMpf15Gvzi1qfroQu+MCU/QLTgJTba2wVJcProX37t4rzVFMHyAjYa AEPlSug/ymagg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nadezda Lutovinova , Greg Kroah-Hartman , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 5.14 217/252] usb: musb: musb_dsps: request_irq() after initializing musb Date: Thu, 9 Sep 2021 07:40:31 -0400 Message-Id: <20210909114106.141462-217-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 7c75bde329d7e2a93cf86a5c15c61f96f1446cdc ] 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 Link: https://lore.kernel.org/r/20210819163323.17714-1-lutovinova@ispras.ru Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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.30.2