https://github.com/torvalds/linux
Revision 1a41741fd60b0a2d1102c3d1ff9d58cb324a8d29 authored by Viresh Kumar on 27 October 2016, 10:20:18 UTC, committed by Lee Jones on 25 November 2016, 11:10:55 UTC
The kernel WARNs and then crashes today if wm8994_device_init() fails
after calling devm_regulator_bulk_get().

That happens because there are multiple devices involved here and the
order in which managed resources are freed isn't correct.

The regulators are added as children of wm8994->dev.  Whereas,
devm_regulator_bulk_get() receives wm8994->dev as the device, though it
gets the same regulators which were added as children of wm8994->dev
earlier.

During failures, the children are removed first and the core eventually
calls regulator_unregister() for them. As regulator_put() was never done
for them (opposite of devm_regulator_bulk_get()), the kernel WARNs at

	WARN_ON(rdev->open_count);

And eventually it crashes from debugfs_remove_recursive().

--------x------------------x----------------

 wm8994 3-001a: Device is not a WM8994, ID is 0
 ------------[ cut here ]------------
 WARNING: CPU: 0 PID: 1 at /mnt/ssd/all/work/repos/devel/linux/drivers/regulator/core.c:4072 regulator_unregister+0xc8/0xd0
 Modules linked in:
 CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.8.0-rc6-00154-g54fe84cbd50b #41
 Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
 [<c010e24c>] (unwind_backtrace) from [<c010af38>] (show_stack+0x10/0x14)
 [<c010af38>] (show_stack) from [<c032a1c4>] (dump_stack+0x88/0x9c)
 [<c032a1c4>] (dump_stack) from [<c011a98c>] (__warn+0xe8/0x100)
 [<c011a98c>] (__warn) from [<c011aa54>] (warn_slowpath_null+0x20/0x28)
 [<c011aa54>] (warn_slowpath_null) from [<c0384a0c>] (regulator_unregister+0xc8/0xd0)
 [<c0384a0c>] (regulator_unregister) from [<c0406434>] (release_nodes+0x16c/0x1dc)
 [<c0406434>] (release_nodes) from [<c04039c4>] (__device_release_driver+0x8c/0x110)
 [<c04039c4>] (__device_release_driver) from [<c0403a64>] (device_release_driver+0x1c/0x28)
 [<c0403a64>] (device_release_driver) from [<c0402b24>] (bus_remove_device+0xd8/0x104)
 [<c0402b24>] (bus_remove_device) from [<c03ffcd8>] (device_del+0x10c/0x218)
 [<c03ffcd8>] (device_del) from [<c0404e4c>] (platform_device_del+0x1c/0x88)
 [<c0404e4c>] (platform_device_del) from [<c0404ec4>] (platform_device_unregister+0xc/0x20)
 [<c0404ec4>] (platform_device_unregister) from [<c0428bc0>] (mfd_remove_devices_fn+0x5c/0x64)
 [<c0428bc0>] (mfd_remove_devices_fn) from [<c03ff9d8>] (device_for_each_child_reverse+0x4c/0x78)
 [<c03ff9d8>] (device_for_each_child_reverse) from [<c04288c4>] (mfd_remove_devices+0x20/0x30)
 [<c04288c4>] (mfd_remove_devices) from [<c042758c>] (wm8994_device_init+0x2ac/0x7f0)
 [<c042758c>] (wm8994_device_init) from [<c04f14a8>] (i2c_device_probe+0x178/0x1fc)
 [<c04f14a8>] (i2c_device_probe) from [<c04036fc>] (driver_probe_device+0x214/0x2c0)
 [<c04036fc>] (driver_probe_device) from [<c0403854>] (__driver_attach+0xac/0xb0)
 [<c0403854>] (__driver_attach) from [<c0401a74>] (bus_for_each_dev+0x68/0x9c)
 [<c0401a74>] (bus_for_each_dev) from [<c0402cf0>] (bus_add_driver+0x1a0/0x218)
 [<c0402cf0>] (bus_add_driver) from [<c040406c>] (driver_register+0x78/0xf8)
 [<c040406c>] (driver_register) from [<c04f20a0>] (i2c_register_driver+0x34/0x84)
 [<c04f20a0>] (i2c_register_driver) from [<c01017d0>] (do_one_initcall+0x40/0x170)
 [<c01017d0>] (do_one_initcall) from [<c0a00dbc>] (kernel_init_freeable+0x15c/0x1fc)
 [<c0a00dbc>] (kernel_init_freeable) from [<c06e07b0>] (kernel_init+0x8/0x114)
 [<c06e07b0>] (kernel_init) from [<c0107978>] (ret_from_fork+0x14/0x3c)
 ---[ end trace 0919d3d0bc998260 ]---

 [snip..]

 Unable to handle kernel NULL pointer dereference at virtual address 00000078
 pgd = c0004000
 [00000078] *pgd=00000000
 Internal error: Oops: 5 [#1] PREEMPT SMP ARM
 Modules linked in:
 CPU: 0 PID: 1 Comm: swapper/0 Tainted: G        W       4.8.0-rc6-00154-g54fe84cbd50b #41
 Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
 task: ee874000 task.stack: ee878000
 PC is at down_write+0x14/0x54
 LR is at debugfs_remove_recursive+0x30/0x150

 [snip..]

 [<c06e489c>] (down_write) from [<c02e9954>] (debugfs_remove_recursive+0x30/0x150)
 [<c02e9954>] (debugfs_remove_recursive) from [<c0382b78>] (_regulator_put+0x24/0xac)
 [<c0382b78>] (_regulator_put) from [<c0382c1c>] (regulator_put+0x1c/0x2c)
 [<c0382c1c>] (regulator_put) from [<c0406434>] (release_nodes+0x16c/0x1dc)
 [<c0406434>] (release_nodes) from [<c04035d4>] (driver_probe_device+0xec/0x2c0)
 [<c04035d4>] (driver_probe_device) from [<c0403854>] (__driver_attach+0xac/0xb0)
 [<c0403854>] (__driver_attach) from [<c0401a74>] (bus_for_each_dev+0x68/0x9c)
 [<c0401a74>] (bus_for_each_dev) from [<c0402cf0>] (bus_add_driver+0x1a0/0x218)
 [<c0402cf0>] (bus_add_driver) from [<c040406c>] (driver_register+0x78/0xf8)
 [<c040406c>] (driver_register) from [<c04f20a0>] (i2c_register_driver+0x34/0x84)
 [<c04f20a0>] (i2c_register_driver) from [<c01017d0>] (do_one_initcall+0x40/0x170)
 [<c01017d0>] (do_one_initcall) from [<c0a00dbc>] (kernel_init_freeable+0x15c/0x1fc)
 [<c0a00dbc>] (kernel_init_freeable) from [<c06e07b0>] (kernel_init+0x8/0x114)
 [<c06e07b0>] (kernel_init) from [<c0107978>] (ret_from_fork+0x14/0x3c)
 Code: e1a04000 f590f000 e3a03001 e34f3fff (e1902f9f)
 ---[ end trace 0919d3d0bc998262 ]---

--------x------------------x----------------

Fix the kernel warnings and crashes by using regulator_bulk_get()
instead of devm_regulator_bulk_get() and explicitly freeing the supplies
in exit paths.

Tested on Exynos 5250, dual core ARM A15 machine.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
1 parent 3cfc43d
History
Tip revision: 1a41741fd60b0a2d1102c3d1ff9d58cb324a8d29 authored by Viresh Kumar on 27 October 2016, 10:20:18 UTC
mfd: wm8994-core: Don't use managed regulator bulk get API
Tip revision: 1a41741
File Mode Size
80211
ABI
DocBook
EDID
PCI
RCU
accounting
acpi
aoe
arm
arm64
auxdisplay
backlight
blackfin
block
blockdev
bus-devices
cdrom
cgroup-v1
cma
connector
console
cpu-freq
cpuidle
cris
crypto
dev-tools
development-process
device-mapper
devicetree
dmaengine
driver-api
driver-model
early-userspace
extcon
fault-injection
fb
features
filesystems
firmware_class
fmc
fpga
frv
gpio
gpu
hid
hwmon
i2c
ia64
ide
iio
infiniband
input
ioctl
isdn
ja_JP
kbuild
kdump
ko_KR
laptops
leds
livepatch
locking
m68k
media
memory-devices
metag
mic
mips
misc-devices
mmc
mn10300
mtd
namespaces
netlabel
networking
nfc
nios2
nvdimm
nvmem
parisc
pcmcia
perf
phy
platform
power
powerpc
pps
prctl
pti
ptp
rapidio
s390
scheduler
scsi
security
serial
sh
sound
sphinx
sphinx-static
spi
sysctl
target
thermal
timers
tpm
trace
usb
virtual
vm
w1
watchdog
wimax
x86
xtensa
zh_CN
.gitignore -rw-r--r-- 13 bytes
00-INDEX -rw-r--r-- 16.8 KB
BUG-HUNTING -rw-r--r-- 8.1 KB
Changes -rw-r--r-- 12.8 KB
CodeOfConflict -rw-r--r-- 1.4 KB
CodingStyle -rw-r--r-- 35.5 KB
DMA-API-HOWTO.txt -rw-r--r-- 34.6 KB
DMA-API.txt -rw-r--r-- 27.8 KB
DMA-ISA-LPC.txt -rw-r--r-- 5.2 KB
DMA-attributes.txt -rw-r--r-- 6.5 KB
HOWTO -rw-r--r-- 27.5 KB
IPMI.txt -rw-r--r-- 29.4 KB
IRQ-affinity.txt -rw-r--r-- 2.5 KB
IRQ-domain.txt -rw-r--r-- 10.6 KB
IRQ.txt -rw-r--r-- 962 bytes
Intel-IOMMU.txt -rw-r--r-- 3.8 KB
Makefile -rw-r--r-- 12 bytes
Makefile.sphinx -rw-r--r-- 3.9 KB
ManagementStyle -rw-r--r-- 13.1 KB
SAK.txt -rw-r--r-- 2.8 KB
SM501.txt -rw-r--r-- 2.8 KB
SecurityBugs -rw-r--r-- 1.9 KB
SubmitChecklist -rw-r--r-- 4.7 KB
SubmittingDrivers -rw-r--r-- 6.3 KB
SubmittingPatches -rw-r--r-- 36.4 KB
VGA-softcursor.txt -rw-r--r-- 2.0 KB
adding-syscalls.txt -rw-r--r-- 23.8 KB
applying-patches.txt -rw-r--r-- 18.5 KB
assoc_array.txt -rw-r--r-- 20.0 KB
atomic_ops.txt -rw-r--r-- 22.0 KB
bad_memory.txt -rw-r--r-- 1.1 KB
basic_profiling.txt -rw-r--r-- 1.7 KB
bcache.txt -rw-r--r-- 23.4 KB
binfmt_misc.txt -rw-r--r-- 7.0 KB
braille-console.txt -rw-r--r-- 1.4 KB
bt8xxgpio.txt -rw-r--r-- 4.3 KB
btmrvl.txt -rw-r--r-- 2.9 KB
bus-virt-phys-mapping.txt -rw-r--r-- 7.9 KB
cachetlb.txt -rw-r--r-- 17.1 KB
cgroup-v2.txt -rw-r--r-- 56.7 KB
circular-buffers.txt -rw-r--r-- 8.4 KB
clk.txt -rw-r--r-- 10.4 KB
conf.py -rw-r--r-- 16.2 KB
cpu-hotplug.txt -rw-r--r-- 16.8 KB
cpu-load.txt -rw-r--r-- 3.0 KB
cputopology.txt -rw-r--r-- 5.3 KB
crc32.txt -rw-r--r-- 8.5 KB
dcdbas.txt -rw-r--r-- 3.6 KB
debugging-modules.txt -rw-r--r-- 954 bytes
debugging-via-ohci1394.txt -rw-r--r-- 7.4 KB
dell_rbu.txt -rw-r--r-- 4.9 KB
devices.txt -rw-r--r-- 115.1 KB
digsig.txt -rw-r--r-- 2.8 KB
dma-buf-sharing.txt -rw-r--r-- 22.0 KB
docutils.conf -rw-r--r-- 158 bytes
dontdiff -rw-r--r-- 2.5 KB
dynamic-debug-howto.txt -rw-r--r-- 12.6 KB
edac.txt -rw-r--r-- 24.7 KB
efi-stub.txt -rw-r--r-- 3.2 KB
eisa.txt -rw-r--r-- 7.1 KB
email-clients.txt -rw-r--r-- 10.8 KB
flexible-arrays.txt -rw-r--r-- 5.5 KB
futex-requeue-pi.txt -rw-r--r-- 5.0 KB
gcc-plugins.txt -rw-r--r-- 2.9 KB
highuid.txt -rw-r--r-- 2.4 KB
hw_random.txt -rw-r--r-- 3.5 KB
hwspinlock.txt -rw-r--r-- 12.7 KB
index.rst -rw-r--r-- 552 bytes
init.txt -rw-r--r-- 2.5 KB
initrd.txt -rw-r--r-- 14.1 KB
intel_txt.txt -rw-r--r-- 10.2 KB
io-mapping.txt -rw-r--r-- 3.2 KB
io_ordering.txt -rw-r--r-- 1.9 KB
iostats.txt -rw-r--r-- 8.0 KB
irqflags-tracing.txt -rw-r--r-- 2.3 KB
isa.txt -rw-r--r-- 5.2 KB
isapnp.txt -rw-r--r-- 433 bytes
java.txt -rw-r--r-- 10.9 KB
kernel-doc-nano-HOWTO.txt -rw-r--r-- 11.8 KB
kernel-docs.txt -rw-r--r-- 25.9 KB
kernel-documentation.rst -rw-r--r-- 23.0 KB
kernel-parameters.txt -rw-r--r-- 160.1 KB
kernel-per-CPU-kthreads.txt -rw-r--r-- 13.2 KB
kobject.txt -rw-r--r-- 18.0 KB
kprobes.txt -rw-r--r-- 30.8 KB
kref.txt -rw-r--r-- 8.4 KB
kselftest.txt -rw-r--r-- 2.5 KB
ldm.txt -rw-r--r-- 3.8 KB
local_ops.txt -rw-r--r-- 6.5 KB
lockup-watchdogs.txt -rw-r--r-- 4.1 KB
logo.gif -rw-r--r-- 16.0 KB
logo.txt -rw-r--r-- 563 bytes
lzo.txt -rw-r--r-- 7.8 KB
magic-number.txt -rw-r--r-- 8.7 KB
mailbox.txt -rw-r--r-- 4.1 KB
md-cluster.txt -rw-r--r-- 12.4 KB
md.txt -rw-r--r-- 25.3 KB
memory-barriers.txt -rw-r--r-- 115.5 KB
memory-hotplug.txt -rw-r--r-- 18.0 KB
men-chameleon-bus.txt -rw-r--r-- 6.1 KB
module-signing.txt -rw-r--r-- 10.6 KB
mono.txt -rw-r--r-- 2.5 KB
nommu-mmap.txt -rw-r--r-- 12.7 KB
ntb.txt -rw-r--r-- 6.3 KB
numastat.txt -rw-r--r-- 836 bytes
oops-tracing.txt -rw-r--r-- 12.8 KB
padata.txt -rw-r--r-- 7.3 KB
parport-lowlevel.txt -rw-r--r-- 32.2 KB
parport.txt -rw-r--r-- 8.8 KB
percpu-rw-semaphore.txt -rw-r--r-- 1.1 KB
phy.txt -rw-r--r-- 7.5 KB
pi-futex.txt -rw-r--r-- 5.7 KB
pinctrl.txt -rw-r--r-- 50.4 KB
pnp.txt -rw-r--r-- 6.8 KB
preempt-locking.txt -rw-r--r-- 5.2 KB
printk-formats.txt -rw-r--r-- 10.3 KB
pwm.txt -rw-r--r-- 6.1 KB
ramoops.txt -rw-r--r-- 5.6 KB
rbtree.txt -rw-r--r-- 13.3 KB
remoteproc.txt -rw-r--r-- 12.7 KB
rfkill.txt -rw-r--r-- 5.0 KB
robust-futex-ABI.txt -rw-r--r-- 8.7 KB
robust-futexes.txt -rw-r--r-- 9.4 KB
rpmsg.txt -rw-r--r-- 13.3 KB
rtc.txt -rw-r--r-- 10.3 KB
serial-console.txt -rw-r--r-- 4.0 KB
sgi-ioc4.txt -rw-r--r-- 2.0 KB
smsc_ece1099.txt -rw-r--r-- 2.4 KB
stable_api_nonsense.txt -rw-r--r-- 9.3 KB
stable_kernel_rules.txt -rw-r--r-- 6.5 KB
static-keys.txt -rw-r--r-- 11.7 KB
svga.txt -rw-r--r-- 14.1 KB
sync_file.txt -rw-r--r-- 3.1 KB
sysfs-rules.txt -rw-r--r-- 9.0 KB
sysrq.txt -rw-r--r-- 11.8 KB
this_cpu_ops.txt -rw-r--r-- 11.1 KB
unaligned-memory-access.txt -rw-r--r-- 10.4 KB
unicode.txt -rw-r--r-- 6.5 KB
unshare.txt -rw-r--r-- 13.1 KB
vfio.txt -rw-r--r-- 21.3 KB
video-output.txt -rw-r--r-- 1.1 KB
vme_api.txt -rw-r--r-- 13.5 KB
volatile-considered-harmful.txt -rw-r--r-- 5.6 KB
workqueue.txt -rw-r--r-- 14.7 KB
xillybus.txt -rw-r--r-- 17.7 KB
xz.txt -rw-r--r-- 5.7 KB
zorro.txt -rw-r--r-- 2.9 KB

back to top