linux-stable/drivers
Thomas Petazzoni 3e4cd06777 net: phy: mdio_bus: add missing device_del() in mdiobus_register() error handling
[ Upstream commit e40e2a2e78 ]

The current code in __mdiobus_register() doesn't properly handle
failures returned by the devm_gpiod_get_optional() call: it returns
immediately, without unregistering the device that was added by the
call to device_register() earlier in the function.

This leaves a stale device, which then causes a NULL pointer
dereference in the code that handles deferred probing:

[    1.489982] Unable to handle kernel NULL pointer dereference at virtual address 00000074
[    1.498110] pgd = (ptrval)
[    1.500838] [00000074] *pgd=00000000
[    1.504432] Internal error: Oops: 17 [#1] SMP ARM
[    1.509133] Modules linked in:
[    1.512192] CPU: 1 PID: 51 Comm: kworker/1:3 Not tainted 4.20.0-00039-g3b73a4cc8b3e-dirty #99
[    1.520708] Hardware name: Xilinx Zynq Platform
[    1.525261] Workqueue: events deferred_probe_work_func
[    1.530403] PC is at klist_next+0x10/0xfc
[    1.534403] LR is at device_for_each_child+0x40/0x94
[    1.539361] pc : [<c0683fbc>]    lr : [<c0455d90>]    psr: 200e0013
[    1.545628] sp : ceeefe68  ip : 00000001  fp : ffffe000
[    1.550863] r10: 00000000  r9 : c0c66790  r8 : 00000000
[    1.556079] r7 : c0457d44  r6 : 00000000  r5 : ceeefe8c  r4 : cfa2ec78
[    1.562604] r3 : 00000064  r2 : c0457d44  r1 : ceeefe8c  r0 : 00000064
[    1.569129] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[    1.576263] Control: 18c5387d  Table: 0ed7804a  DAC: 00000051
[    1.582013] Process kworker/1:3 (pid: 51, stack limit = 0x(ptrval))
[    1.588280] Stack: (0xceeefe68 to 0xceef0000)
[    1.592630] fe60:                   cfa2ec78 c0c03c08 00000000 c0457d44 00000000 c0c66790
[    1.600814] fe80: 00000000 c0455d90 ceeefeac 00000064 00000000 0d7a542e cee9d494 cfa2ec78
[    1.608998] fea0: cfa2ec78 00000000 c0457d44 c0457d7c cee9d494 c0c03c08 00000000 c0455dac
[    1.617182] fec0: cf98ba44 cf926a00 cee9d494 0d7a542e 00000000 cf935a10 cf935a10 cf935a10
[    1.625366] fee0: c0c4e9b8 c0457d7c c0c4e80c 00000001 cf935a10 c0457df4 cf935a10 c0c4e99c
[    1.633550] ff00: c0c4e99c c045a27c c0c4e9c4 ced63f80 cfde8a80 cfdebc00 00000000 c013893c
[    1.641734] ff20: cfde8a80 cfde8a80 c07bd354 ced63f80 ced63f94 cfde8a80 00000008 c0c02d00
[    1.649936] ff40: cfde8a98 cfde8a80 ffffe000 c0139a30 ffffe000 c0c6624a c07bd354 00000000
[    1.658120] ff60: ffffe000 cee9e780 ceebfe00 00000000 ceeee000 ced63f80 c0139788 cf8cdea4
[    1.666304] ff80: cee9e79c c013e598 00000001 ceebfe00 c013e44c 00000000 00000000 00000000
[    1.674488] ffa0: 00000000 00000000 00000000 c01010e8 00000000 00000000 00000000 00000000
[    1.682671] ffc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    1.690855] ffe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
[    1.699058] [<c0683fbc>] (klist_next) from [<c0455d90>] (device_for_each_child+0x40/0x94)
[    1.707241] [<c0455d90>] (device_for_each_child) from [<c0457d7c>] (device_reorder_to_tail+0x38/0x88)
[    1.716476] [<c0457d7c>] (device_reorder_to_tail) from [<c0455dac>] (device_for_each_child+0x5c/0x94)
[    1.725692] [<c0455dac>] (device_for_each_child) from [<c0457d7c>] (device_reorder_to_tail+0x38/0x88)
[    1.734927] [<c0457d7c>] (device_reorder_to_tail) from [<c0457df4>] (device_pm_move_to_tail+0x28/0x40)
[    1.744235] [<c0457df4>] (device_pm_move_to_tail) from [<c045a27c>] (deferred_probe_work_func+0x58/0x8c)
[    1.753746] [<c045a27c>] (deferred_probe_work_func) from [<c013893c>] (process_one_work+0x210/0x4fc)
[    1.762888] [<c013893c>] (process_one_work) from [<c0139a30>] (worker_thread+0x2a8/0x5c0)
[    1.771072] [<c0139a30>] (worker_thread) from [<c013e598>] (kthread+0x14c/0x154)
[    1.778482] [<c013e598>] (kthread) from [<c01010e8>] (ret_from_fork+0x14/0x2c)
[    1.785689] Exception stack(0xceeeffb0 to 0xceeefff8)
[    1.790739] ffa0:                                     00000000 00000000 00000000 00000000
[    1.798923] ffc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    1.807107] ffe0: 00000000 00000000 00000000 00000000 00000013 00000000
[    1.813724] Code: e92d47f0 e1a05000 e8900048 e1a00003 (e5937010)
[    1.819844] ---[ end trace 3c2c0c8b65399ec9 ]---

The actual error that we had from devm_gpiod_get_optional() was
-EPROBE_DEFER, due to the GPIO being provided by a driver that is
probed later than the Ethernet controller driver.

To fix this, we simply add the missing device_del() invocation in the
error path.

Fixes: 69226896ad ("mdio_bus: Issue GPIO RESET to PHYs")
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-01-31 08:14:31 +01:00
..
accessibility
acpi ACPI/IORT: Fix rc_dma_get_range() 2019-01-16 22:04:34 +01:00
amba
android binder: fix race that allows malicious free of live buffer 2018-12-05 19:32:11 +01:00
ata libata: whitelist all SAMSUNG MZ7KM* solid-state disks 2018-12-21 14:15:20 +01:00
atm
auxdisplay auxdisplay: charlcd: fix x/y command parsing 2019-01-13 09:51:03 +01:00
base sysfs: Disable lockdep for driver bind/unbind files 2019-01-26 09:32:42 +01:00
bcma
block nbd: Use set_blocksize() to set device blocksize 2019-01-22 21:40:38 +01:00
bluetooth Bluetooth: btusb: Add support for Intel bluetooth device 8087:0029 2019-01-26 09:32:42 +01:00
bus Merge branch 'perm-fix' into omap-for-v4.19/fixes-v2 2018-08-28 09:58:03 -07:00
cdrom cdrom: fix improper type cast, which can leat to information leak. 2018-11-21 09:19:12 +01:00
char ipmi: Don't initialize anything in the core until something uses it 2019-01-26 09:32:44 +01:00
clk clk: imx6q: reset exclusive gates on init 2019-01-26 09:32:38 +01:00
clocksource clocksource/drivers/integrator-ap: Add missing of_node_put() 2019-01-26 09:32:42 +01:00
connector
cpufreq cpufreq: scmi: Fix frequency invariance in slow path 2019-01-16 22:04:29 +01:00
cpuidle powerpc/pseries/cpuidle: Fix preempt warning 2019-01-26 09:32:37 +01:00
crypto crypto: talitos - fix ablkcipher for CONFIG_VMAP_STACK 2019-01-22 21:40:32 +01:00
dax mm, devm_memremap_pages: fix shutdown handling 2019-01-13 09:51:04 +01:00
dca
devfreq Char/Misc driver patches for 4.19-rc1 2018-08-18 11:04:51 -07:00
dio
dma dmaengine: cppi41: delete channel from pending list when stop channel 2018-12-13 09:16:20 +01:00
dma-buf
edac EDAC, skx_edac: Fix logical channel intermediate decoding 2018-11-13 11:08:44 -08:00
eisa
extcon
firewire firewire: use 64-bit time_t based interfaces 2018-08-17 16:20:27 -07:00
firmware efi/libstub: Disable some warnings for x86{,_64} 2019-01-26 09:32:36 +01:00
fmc
fpga fpga: altera-cvp: fix probing for multiple FPGAs on the bus 2019-01-26 09:32:36 +01:00
fsi fsi: master-ast-cf: select GENERIC_ALLOCATOR 2018-12-17 09:24:35 +01:00
gnss gnss: sirf: fix activation retry handling 2018-12-13 09:16:22 +01:00
gpio gpio: pl061: Move irq_chip definition inside struct pl061 2019-01-26 09:32:33 +01:00
gpu drm/amdgpu: Reorder uvd ring init before uvd resume 2019-01-26 09:32:36 +01:00
hid HID: ite: Add USB id match for another ITE based keyboard rfkill key quirk 2019-01-13 09:50:56 +01:00
hsi
hv x86, hyperv: remove PCI dependency 2019-01-13 09:51:00 +01:00
hwmon hwmon: (w83795) temp4_type has writable permission 2018-12-17 09:24:33 +01:00
hwspinlock
hwtracing intel_th: msu: Fix an off-by-one in attribute store 2019-01-13 09:51:10 +01:00
i2c i2c: dev: prevent adapter retries and timeout being set as minus value 2019-01-16 22:04:34 +01:00
ide ide: pmac: add of_node_put() 2018-12-21 14:15:18 +01:00
idle
iio iio: dac: ad5686: fix bit shift read register 2019-01-13 09:51:08 +01:00
infiniband IB/usnic: Fix potential deadlock 2019-01-26 09:32:42 +01:00
input Input: synaptics - enable SMBus for HP EliteBook 840 G4 2019-01-13 09:51:03 +01:00
iommu iommu/vt-d: Handle domain agaw being less than iommu agaw 2019-01-13 09:51:09 +01:00
ipack
irqchip irqchip/pdc: Setup all edge interrupts as rising edge at GIC 2018-11-13 11:08:34 -08:00
isdn isdn: fix kernel-infoleak in capi_unlocked_ioctl 2019-01-09 17:38:31 +01:00
leds leds: pwm: silently error out on EPROBE_DEFER 2019-01-13 09:51:08 +01:00
lightnvm lightnvm: pblk: fix race condition on metadata I/O 2018-11-13 11:08:21 -08:00
macintosh macintosh: therm_windtunnel: drop using attach_adapter 2018-08-24 14:42:42 +02:00
mailbox mailbox: PCC: handle parse error 2018-11-13 11:08:18 -08:00
mcb
md dm: Check for device sector overflow if CONFIG_LBDAF is not set 2019-01-26 09:32:42 +01:00
media media: venus: core: Set dma maximum segment size 2019-01-26 09:32:38 +01:00
memory memory: ti-aemif: fix a potential NULL-pointer dereference 2018-09-06 10:04:07 -07:00
memstick
message
mfd mfd: tps6586x: Handle interrupts on suspend 2019-01-22 21:40:33 +01:00
misc genwqe: Fix size check 2019-01-13 09:51:10 +01:00
mmc mmc: atmel-mci: do not assume idle after atmci_request_end 2019-01-26 09:32:39 +01:00
mtd mtd: rawnand: qcom: fix memory corruption that causes panic 2019-01-16 22:04:34 +01:00
mux mux: adgs1408: use the correct MODULE_LICENSE 2018-10-12 17:36:39 +02:00
net net: phy: mdio_bus: add missing device_del() in mdiobus_register() error handling 2019-01-31 08:14:31 +01:00
nfc NFC: nfcmrvl_uart: fix OF child-node lookup 2018-11-13 11:08:48 -08:00
ntb
nubus
nvdimm mm, devm_memremap_pages: fix shutdown handling 2019-01-13 09:51:04 +01:00
nvme nvmet-rdma: fix response use after free 2018-12-21 14:15:25 +01:00
nvmem nvmem: check the return value of nvmem_add_cells() 2018-11-13 11:08:35 -08:00
of of: overlay: add missing of_node_put() after add new node to changeset 2019-01-26 09:32:34 +01:00
opp opp: ti-opp-supply: Correct the supply in _get_optimal_vdd_voltage call 2018-12-01 09:37:27 +01:00
oprofile
parisc
parport Char/Misc driver patches for 4.19-rc1 2018-08-18 11:04:51 -07:00
pci PCI: dwc: Move interrupt acking into the proper callback 2019-01-16 22:04:35 +01:00
pcmcia pcmcia: Implement CLKRUN protocol disabling for Ricoh bridges 2018-11-13 11:08:17 -08:00
perf drivers/perf: hisi: Fixup one DDRC PMU register offset 2019-01-13 09:51:10 +01:00
phy phy: qcom-qusb2: Fix HSTX_TRIM tuning with fused value for SDM845 2018-12-17 09:24:34 +01:00
pinctrl pinctrl: meson: fix pull enable register calculation 2019-01-13 09:50:54 +01:00
platform platform/x86: asus-wmi: Tell the EC the OS will handle the display off hotkey 2019-01-26 09:32:34 +01:00
pnp
power power: supply: olpc_battery: correct the temperature units 2019-01-13 09:51:10 +01:00
powercap
pps
ps3
ptp ptp: fix Spectre v1 vulnerability 2018-10-17 22:00:22 -07:00
pwm pwm: mediatek: Add MT7628 support 2018-08-20 11:36:07 +02:00
rapidio drivers/rapidio/devices/rio_mport_cdev.c: remove redundant pointer md 2018-08-22 10:52:51 -07:00
ras
regulator regulator: fix crash caused by null driver data 2018-09-20 09:04:51 -07:00
remoteproc remoteproc: qcom: q6v5: Propagate EPROBE_DEFER 2018-11-13 11:08:52 -08:00
reset ARM: SoC: late updates 2018-08-25 14:12:36 -07:00
rpmsg rpmsg: smd: fix memory leak on channel create 2018-11-13 11:08:55 -08:00
rtc rtc: m41t80: Correct alarm month range with RTC reads 2019-01-09 17:38:48 +01:00
s390 scsi: zfcp: fix posting too many status read buffers leading to adapter shutdown 2019-01-13 09:51:03 +01:00
sbus drivers/sbus/char: add of_node_put() 2018-12-21 14:15:17 +01:00
scsi scsi: megaraid: fix out-of-bound array accesses 2019-01-26 09:32:43 +01:00
sfi
sh sh: introduce a sh_cacheop_vaddr helper 2018-08-02 13:54:06 +02:00
siox
slimbus slimbus: ngd: mark PM functions as __maybe_unused 2018-12-19 19:19:49 +01:00
sn
soc soc: ti: QMSS: Fix usage of irq_set_affinity_hint 2018-11-21 09:19:18 +01:00
soundwire soundwire: Fix acquiring bus lock twice during master release 2018-08-27 09:49:48 +05:30
spi spi: bcm2835: Unbreak the build of esoteric configs 2019-01-09 17:38:49 +01:00
spmi
ssb ssb: Remove SSB_WARN_ON, SSB_BUG_ON and SSB_DEBUG 2018-08-09 18:47:47 +03:00
staging staging: erofs: fix use-after-free of on-stack `z_erofs_vle_unzip_io' 2019-01-26 09:32:38 +01:00
target scsi: target/core: Make sure that target_wait_for_sess_cmds() waits long enough 2019-01-26 09:32:38 +01:00
tc TC: Set DMA masks for devices 2018-11-13 11:08:51 -08:00
tee ARM: SoC driver updates 2018-08-23 13:52:46 -07:00
thermal thermal: armada: fix legacy validity test sense 2018-12-21 14:15:22 +01:00
thunderbolt thunderbolt: Prevent root port runtime suspend during NVM upgrade 2018-12-17 09:24:36 +01:00
tty tty/serial: do not free trasnmit buffer page under port lock 2019-01-26 09:32:40 +01:00
uio uio: Fix an Oops on load 2018-11-27 16:13:09 +01:00
usb usb: gadget: udc: renesas_usb3: add a safety connection way for forced_b_device 2019-01-26 09:32:36 +01:00
uwb
vfio vfio/type1: Fix unmap overflow off-by-one 2019-01-16 22:04:34 +01:00
vhost vhost: make sure used idx is seen before log in vhost_add_used_n() 2019-01-09 17:38:34 +01:00
video omap2fb: Fix stack memory disclosure 2019-01-22 21:40:34 +01:00
virt
virtio virtio, vhost: fixes, tweaks 2018-08-24 08:45:19 -07:00
visorbus
vlynq
vme
w1 w1: omap-hdq: fix missing bus unregister at removal 2018-11-13 11:08:48 -08:00
watchdog include/linux/compiler*.h: make compiler-*.h mutually exclusive 2018-08-22 17:31:34 -07:00
xen xen: Fix x86 sched_clock() interface for xen 2019-01-22 21:40:32 +01:00
zorro
Kconfig
Makefile Char/Misc driver patches for 4.19-rc1 2018-08-18 11:04:51 -07:00