Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4310455pxu; Tue, 1 Dec 2020 01:34:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPAf/UpThpf3bkRDPsXVma81CqAe6Qhm8JavioXs+Ak8NRHBEhFpVU6g4zXaJd71x9WtUF X-Received: by 2002:a50:e786:: with SMTP id b6mr2012654edn.242.1606815268432; Tue, 01 Dec 2020 01:34:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606815268; cv=none; d=google.com; s=arc-20160816; b=QjX9JTSiqWF6WDeRErrr5ALEDzrqYV2OTHr3uShRgLdzNENwFYZFGu9MVb7GJVc9mx cJfpAojBdeg/1KRs7xEApWFcuAGGETPMzrNX3SWYbKfy2LOeIFaDuq7CX4+fE4LU2eh6 6dnnf270WehXBjogbQzbi7l+Lc1tMPCFxiJWd+ssAR/EtwjFz8uHmiE6V2x5dxAcsFMO EXivu6OEftBm7gZyqdMbVvEfghM3ewWIFwkU6yVbSriPg+HbQt5kwUblWAG9HzOVlc8M 0TIwqHVmMsEsuAR/rPDwWZb44pJK1k8ysZXIhfnfa/s8jQwgDhnBxYjK5r89i4G8VF4O yqkQ== 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=HFqI3r4Ir7QdNpK1arUErqWsBRv7ZxFOxTzi0HGUV+o=; b=NLEW0L2SFiK/vsDvsSnOhO8HsFs7WrTCN2cM2CfD/lwUpulEE8/nmlGZYuNAreG+dz FBb7/F3VI7OIoKAA76fubo+CbvAq5l4YOhrRFMRH6bzNcTA1jg7JmEqxLUKftYiibPrh 3m0zAK4pgWKDZtcJiS7yiVIb86u+pSnrCIEFB2n5hz37pg+Jt5bSIPJYk83YcSLNADf9 nLlGKEi+HMMf5Nxo1Z0m0JVxldG57NlIhh3hsAMca/gRJsSthO4N6QTSrIZZw1ZqWo+K X3rUSG28xFSis709d8qA/R3GaT2c+jRFhFwSLGJTP2GDAISUmuVzAdj4qygGp9B3FI1o NJjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y6e2DXO5; 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 m10si782580eds.453.2020.12.01.01.34.06; Tue, 01 Dec 2020 01:34:28 -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=Y6e2DXO5; 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 S2387531AbgLAIzn (ORCPT + 99 others); Tue, 1 Dec 2020 03:55:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:57750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387500AbgLAIzh (ORCPT ); Tue, 1 Dec 2020 03:55:37 -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 333C12222C; Tue, 1 Dec 2020 08:55:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606812921; bh=HsO/PP1epoLExfRcIVAww0DhtBUvWcf87NgyCQrsquc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y6e2DXO5FEnnx0c+VFAVbIrCqlrKuT+X/KO4jRfKmUxCnVaDMmQvWBux1MyT3gdXu O11m9bo5LFRS3SyFY7LHwCC2FFGVnNtxwvlggTgGzf2EeQYM+6bGW1kIpdkP6JqbvG WBYytOGXD2Q0KGGBK6GNiIA0yiBBoLj8pwjp8L+w= 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 4.9 21/42] phy: tegra: xusb: Fix dangling pointer on probe failure Date: Tue, 1 Dec 2020 09:53:19 +0100 Message-Id: <20201201084643.696079174@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084642.194933793@linuxfoundation.org> References: <20201201084642.194933793@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 bd0e659002161..0156134dd022d 100644 --- a/drivers/phy/tegra/xusb.c +++ b/drivers/phy/tegra/xusb.c @@ -916,6 +916,7 @@ remove_pads: reset: reset_control_assert(padctl->rst); remove: + platform_set_drvdata(pdev, NULL); soc->ops->remove(padctl); return err; } -- 2.27.0