Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp405554pxu; Tue, 1 Dec 2020 14:26:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxiXY61S15pd1mgQOnOoF8E4NHqeiC6MjBxSW4ZJySompKRxSxGxKVfNTyt1LyJy1gsErRI X-Received: by 2002:a17:906:7016:: with SMTP id n22mr5055604ejj.402.1606861594157; Tue, 01 Dec 2020 14:26:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606861594; cv=none; d=google.com; s=arc-20160816; b=t3EctGVS4OQs9wGsp0ktqG+6QIWrCRU4KzaFe7L7fj6uaKx8rIRgksZEtfvantBVn1 zFAN5ap0RcPt5b42hbW4SDyv4f7vN8f9dUCvMG8nDIzju0a8hoc5jXWPdxGVt5Vgg/+W lQ7VTW6hYlXWU4GOh2AWwEsW/KhykoumZlEBPvqoh6EC/XPLwVDIsmE5228TlqJS5vQO 5v4O1n0Z3oozS9pPRsrrg+d7GP0uxhmsQScaFJJX37W2R505Nyd4Px4YGuGHtAk/Qd44 xL/gPh9Audht5o8LSXKwTvsmV0bQZmVFl5O2M+4RpdCTc6H6cSM48IcMpD/k9AzrfFMx 6raA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9Q2dTvS/GCkn28WmwLb9BWKQCITpo7yurydRqO692sQ=; b=BP9xAcDh/GpXzzYAnk8xXZLn+JGUKz5Uh7D/6rIODIi+QD8EoCegDW9hjaNaV/VVRH twKbvwP3YDj601AX7LkPjEiF+hrVgZ8quzy+elWcAnB9ZkmEzm4NRoE7+O+1KW2ryPLi a7HJmE99dNYMXO7UKT77KIRPHDBvA+JLcaR/yLYB8Ci9zpZhkISm0v4ywbLPcZCbCxuI NCX9P54/Q9QwphfPs9jshvUbhO9DesTKZv1a6Rnx6MVatyx/TSRWLZcU285We+fFOQRL 6XXSsCoImQ0je82P9dkFNOX7+RpzCz04lCa2dv4A4uBrk3ZYho1ISefS+8JnR6pu1QU0 rLGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xYmst837; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si838908ejk.428.2020.12.01.14.26.11; Tue, 01 Dec 2020 14:26:34 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=xYmst837; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389823AbgLAJLP (ORCPT + 99 others); Tue, 1 Dec 2020 04:11:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:48854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389805AbgLAJLM (ORCPT ); Tue, 1 Dec 2020 04:11:12 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 322C72067D; Tue, 1 Dec 2020 09:10:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813825; bh=JPA/yCCNa/xybkpeTlqzFUPnvJbpnpTyHlzNEN+EP1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xYmst837Q/TE8DnftFOEvxSRfCUpBvTvpJxflsqbY9Xb7StG5t73hgWIFnzwvMtC+ H3Uh7KvcnjNk8aCntsH8xiJ/Y5xPb6L6uXjm4EPKdeT+KwNBgmVIl9c81nLrkcRmI/ 4BJAShCZ3ed41f+1H/fKUc79DQw6ZrA2xKtdP4fc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Vinod Koul , Sasha Levin Subject: [PATCH 5.9 072/152] phy: tegra: xusb: Fix dangling pointer on probe failure Date: Tue, 1 Dec 2020 09:53:07 +0100 Message-Id: <20201201084721.363189907@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084711.707195422@linuxfoundation.org> References: <20201201084711.707195422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier [ Upstream commit eb9c4dd9bdfdebaa13846c16a8c79b5b336066b6 ] If, for some reason, the xusb PHY fails to probe, it leaves a dangling pointer attached to the platform device structure. This would normally be harmless, but the Tegra XHCI driver then goes and extract that pointer from the PHY device. Things go downhill from there: 8.752082] [004d554e5145533c] address between user and kernel address ranges [ 8.752085] Internal error: Oops: 96000004 [#1] PREEMPT SMP [ 8.752088] Modules linked in: max77620_regulator(E+) xhci_tegra(E+) sdhci_tegra(E+) xhci_hcd(E) sdhci_pltfm(E) cqhci(E) fixed(E) usbcore(E) scsi_mod(E) sdhci(E) host1x(E+) [ 8.752103] CPU: 4 PID: 158 Comm: systemd-udevd Tainted: G S W E 5.9.0-rc7-00298-gf6337624c4fe #1980 [ 8.752105] Hardware name: NVIDIA Jetson TX2 Developer Kit (DT) [ 8.752108] pstate: 20000005 (nzCv daif -PAN -UAO BTYPE=--) [ 8.752115] pc : kobject_put+0x1c/0x21c [ 8.752120] lr : put_device+0x20/0x30 [ 8.752121] sp : ffffffc012eb3840 [ 8.752122] x29: ffffffc012eb3840 x28: ffffffc010e82638 [ 8.752125] x27: ffffffc008d56440 x26: 0000000000000000 [ 8.752128] x25: ffffff81eb508200 x24: 0000000000000000 [ 8.752130] x23: ffffff81eb538800 x22: 0000000000000000 [ 8.752132] x21: 00000000fffffdfb x20: ffffff81eb538810 [ 8.752134] x19: 3d4d554e51455300 x18: 0000000000000020 [ 8.752136] x17: ffffffc008d00270 x16: ffffffc008d00c94 [ 8.752138] x15: 0000000000000004 x14: ffffff81ebd4ae90 [ 8.752140] x13: 0000000000000000 x12: ffffff81eb86a4e8 [ 8.752142] x11: ffffff81eb86a480 x10: ffffff81eb862fea [ 8.752144] x9 : ffffffc01055fb28 x8 : ffffff81eb86a4a8 [ 8.752146] x7 : 0000000000000001 x6 : 0000000000000001 [ 8.752148] x5 : ffffff81dff8bc38 x4 : 0000000000000000 [ 8.752150] x3 : 0000000000000001 x2 : 0000000000000001 [ 8.752152] x1 : 0000000000000002 x0 : 3d4d554e51455300 [ 8.752155] Call trace: [ 8.752157] kobject_put+0x1c/0x21c [ 8.752160] put_device+0x20/0x30 [ 8.752164] tegra_xusb_padctl_put+0x24/0x3c [ 8.752170] tegra_xusb_probe+0x8b0/0xd10 [xhci_tegra] [ 8.752174] platform_drv_probe+0x60/0xb4 [ 8.752176] really_probe+0xf0/0x504 [ 8.752179] driver_probe_device+0x100/0x170 [ 8.752181] device_driver_attach+0xcc/0xd4 [ 8.752183] __driver_attach+0xb0/0x17c [ 8.752185] bus_for_each_dev+0x7c/0xd4 [ 8.752187] driver_attach+0x30/0x3c [ 8.752189] bus_add_driver+0x154/0x250 [ 8.752191] driver_register+0x84/0x140 [ 8.752193] __platform_driver_register+0x54/0x60 [ 8.752197] tegra_xusb_init+0x40/0x1000 [xhci_tegra] [ 8.752201] do_one_initcall+0x54/0x2d0 [ 8.752205] do_init_module+0x68/0x29c [ 8.752207] load_module+0x2178/0x26c0 [ 8.752209] __do_sys_finit_module+0xb0/0x120 [ 8.752211] __arm64_sys_finit_module+0x2c/0x40 [ 8.752215] el0_svc_common.constprop.0+0x80/0x240 [ 8.752218] do_el0_svc+0x30/0xa0 [ 8.752220] el0_svc+0x18/0x50 [ 8.752223] el0_sync_handler+0x90/0x318 [ 8.752225] el0_sync+0x158/0x180 [ 8.752230] Code: a9bd7bfd 910003fd a90153f3 aa0003f3 (3940f000) [ 8.752232] ---[ end trace 90f6c89d62d85ff5 ]--- Reset the pointer on probe failure fixes the issue. Fixes: 53d2a715c2403 ("phy: Add Tegra XUSB pad controller support") Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20201013095820.311376-1-maz@kernel.org Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/phy/tegra/xusb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c index de4a46fe17630..ad88d74c18842 100644 --- a/drivers/phy/tegra/xusb.c +++ b/drivers/phy/tegra/xusb.c @@ -1242,6 +1242,7 @@ power_down: reset: reset_control_assert(padctl->rst); remove: + platform_set_drvdata(pdev, NULL); soc->ops->remove(padctl); return err; } -- 2.27.0