linux/drivers/usb/phy
Artur Petrosyan 3d11de2d57 usb: phy: Fix page fault from usb_phy_uevent
When the dwc2 platform device is removed, it unregisters the generic
phy. usb_remove_phy() is called and the dwc2 usb_phy is removed from the
"phy_list", but the uevent may still attempt to get the usb_phy from the
list, resulting in a page fault bug. Currently we can't access the usb_phy
from the "phy_list" after the device is removed. As a fix check to make
sure that we can get the usb_phy before moving forward with the uevent.

[   84.949345] BUG: unable to handle page fault for address:00000007935688d8
[   84.949349] #PF: supervisor read access in kernel mode
[   84.949351] #PF: error_code(0x0000) - not-present page
[   84.949353] PGD 0 P4D 0
[   84.949356] Oops: 0000 [#1] SMP PTI
[   84.949360] CPU: 2 PID: 2081 Comm: rmmod Not tainted 5.13.0-rc4-snps-16547-ga8534cb092d7-dirty #32
[   84.949363] Hardware name: Hewlett-Packard HP Z400 Workstation/0B4Ch, BIOS 786G3 v03.54 11/02/2011
[   84.949365] RIP: 0010:usb_phy_uevent+0x99/0x121
[   84.949372] Code: 8d 83 f8 00 00 00 48 3d b0 12 22 94 74 05 4c 3b 23
75 5b 8b 83 9c 00 00 00 be 32 00 00 00 48 8d 7c 24 04 48 c7 c2 d4 5d 7b
93 <48> 8b 0c c5 e0 88 56 93 e8 0f 63 8a ff 8b 83 98 00 00 00 be 32 00
[   84.949375] RSP: 0018:ffffa46bc0f2fc70 EFLAGS: 00010246
[   84.949378] RAX: 00000000ffffffff RBX: ffffffff942211b8 RCX: 0000000000000027
[   84.949380] RDX: ffffffff937b5dd4 RSI: 0000000000000032 RDI: ffffa46bc0f2fc74
[   84.949383] RBP: ffff94a306613000 R08: 0000000000000000 R09: 00000000fffeffff
[   84.949385] R10: ffffa46bc0f2faa8 R11: ffffa46bc0f2faa0 R12: ffff94a30186d410
[   84.949387] R13: ffff94a32d188a80 R14: ffff94a30029f960 R15: ffffffff93522dd0
[   84.949389] FS:  00007efdbd417540(0000) GS:ffff94a513a80000(0000) knlGS:0000000000000000
[   84.949392] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   84.949394] CR2: 00000007935688d8 CR3: 0000000165606000 CR4: 00000000000006e0
[   84.949396] Call Trace:
[   84.949401]  dev_uevent+0x190/0x1ad
[   84.949408]  kobject_uevent_env+0x18e/0x46c
[   84.949414]  device_release_driver_internal+0x17f/0x18e
[   84.949418]  bus_remove_device+0xd3/0xe5
[   84.949421]  device_del+0x1c3/0x31d
[   84.949425]  ? kobject_put+0x97/0xa8
[   84.949428]  platform_device_del+0x1c/0x63
[   84.949432]  platform_device_unregister+0xa/0x11
[   84.949436]  dwc2_pci_remove+0x1e/0x2c [dwc2_pci]
[   84.949440]  pci_device_remove+0x31/0x81
[   84.949445]  device_release_driver_internal+0xea/0x18e
[   84.949448]  driver_detach+0x68/0x72
[   84.949450]  bus_remove_driver+0x63/0x82
[   84.949453]  pci_unregister_driver+0x1a/0x75
[   84.949457]  __do_sys_delete_module+0x149/0x1e9
[   84.949462]  ? task_work_run+0x64/0x6e
[   84.949465]  ? exit_to_user_mode_prepare+0xd4/0x10d
[   84.949471]  do_syscall_64+0x5d/0x70
[   84.949475]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[   84.949480] RIP: 0033:0x7efdbd563bcb
[   84.949482] Code: 73 01 c3 48 8b 0d c5 82 0c 00 f7 d8 64 89 01 48 83
c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa b8 b0 00 00 00 0f
05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 95 82 0c 00 f7 d8 64 89 01 48
[   84.949485] RSP: 002b:00007ffe944d7d98 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
[   84.949489] RAX: ffffffffffffffda RBX: 00005651072eb700 RCX: 00007efdbd563bcb
[   84.949491] RDX: 000000000000000a RSI: 0000000000000800 RDI: 00005651072eb768
[   84.949493] RBP: 00007ffe944d7df8 R08: 0000000000000000 R09: 0000000000000000
[   84.949495] R10: 00007efdbd5dfac0 R11: 0000000000000206 R12: 00007ffe944d7fd0
[   84.949497] R13: 00007ffe944d8610 R14: 00005651072eb2a0 R15: 00005651072eb700
[   84.949500] Modules linked in: uas configfs dwc2_pci(-) phy_generic fuse crc32c_intel [last unloaded: udc_core]
[   84.949508] CR2: 00000007935688d8
[   84.949510] ---[ end trace e40c871ca3e4dc9e ]---
[   84.949512] RIP: 0010:usb_phy_uevent+0x99/0x121

Fixes: a8534cb092 ("usb: phy: introduce usb_phy device type with its own uevent handler")
Reviewed-by: Peter Chen <peter.chen@kernel.org>
Signed-off-by: Artur Petrosyan <Arthur.Petrosyan@synopsys.com>
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://lore.kernel.org/r/20210710092247.D7AFEA005D@mailhost.synopsys.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-21 09:48:36 +02:00
..
Kconfig usb: phy: Fix spelling mistake in Kconfig help text 2020-12-09 15:23:47 +01:00
Makefile usb: phy: Add driver for the Ingenic JZ4770 USB transceiver 2020-03-12 09:53:08 +01:00
of.c USB: phy: Remove redundant license text 2017-11-07 15:45:01 +01:00
phy-ab8500-usb.c usb: phy: phy-ab8500-usb: fix spello of "function" 2020-09-14 16:50:48 +02:00
phy-am335x-control.c usb: phy: am335x: convert to devm_platform_ioremap_resource_byname 2020-07-29 16:49:37 +02:00
phy-am335x-control.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
phy-am335x.c usb: phy-generic: Delete unused platform data 2020-01-15 10:39:20 +01:00
phy-fsl-usb.c usb: phy: Use fallthrough pseudo-keyword 2020-07-10 08:55:17 +02:00
phy-fsl-usb.h USB: phy: fsl-usb: remove character device usage 2020-07-03 10:18:41 +02:00
phy-generic.c usb: phy-generic: Delete unused platform data 2020-01-15 10:39:20 +01:00
phy-generic.h usb: phy-generic: Delete unused platform data 2020-01-15 10:39:20 +01:00
phy-gpio-vbus-usb.c usb: phy: phy-gpio-vbus-usb: Convert to GPIO descriptors 2020-01-23 19:20:57 +01:00
phy-isp1301-omap.c usb: phy: Use fallthrough pseudo-keyword 2021-05-10 11:16:11 +02:00
phy-isp1301.c usb: phy: isp1301: Deduplicate of_find_i2c_device_by_node() 2021-05-24 15:27:17 +02:00
phy-jz4770.c USB: PHY: JZ4770: Remove unnecessary function calls. 2020-12-05 13:39:30 +05:30
phy-keystone.c usb: phy: Replace HTTP links with HTTPS ones 2020-07-15 16:33:51 +02:00
phy-mv-usb.c usb: phy: phy-mv-usb: convert to readl_poll_timeout_atomic() 2020-09-25 16:30:06 +02:00
phy-mv-usb.h USB: phy: Use the correct style for SPDX License Identifier 2020-04-23 15:28:14 +02:00
phy-mxs-usb.c usb: phy: phy-mxs-usb: Use of_device_get_match_data() 2021-01-18 18:35:46 +01:00
phy-omap-otg.c USB: phy: Remove redundant license text 2017-11-07 15:45:01 +01:00
phy-tahvo.c USB: phy: tahvo: convert platform driver to use dev_groups 2019-08-09 07:55:44 +02:00
phy-tegra-usb.c usb: phy: tegra: Correct definition of B_SESS_VLD_WAKEUP_EN bit 2021-06-15 15:36:23 +02:00
phy-twl6030-usb.c usb: phy: Replace HTTP links with HTTPS ones 2020-07-15 16:33:51 +02:00
phy-ulpi-viewport.c usb: phy-ulpi-viewport: convert to readl_poll_timeout_atomic() 2020-09-25 16:30:05 +02:00
phy-ulpi.c usb: ulpi: Add resource-managed variant of otg_ulpi_create() 2020-01-09 16:21:57 +01:00
phy.c usb: phy: Fix page fault from usb_phy_uevent 2021-07-21 09:48:36 +02:00