linux/drivers
Srinivas Kandagatla af33873cc7 clk: Fix debugfs clk removal before inited
commit 52bba9809a upstream.

Some of the clks can be registered & unregistered before the clk related debugfs
entries are initialized at late_initcall. In the unregister path checking for only
dentry before clk_debug_init() would lead dangling pointers in the debug clk list,
because the list is already populated in register path and the clk pointer freed in
unregister path.
The side effect of not removing it from the list is either a null pointer
dereference or if lucky to boot the system, the number of clk entries in
debugfs disappear.

We could add more checks like if (inited && !clk->dentry) but just removing
the check for dentry made more sense as debugfs_remove_recursive() seems to be
safe with null pointers. This will ensure that the unregistering clk would be
removed from the debug list in all the code paths.

Without this patch kernel would crash with log:
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = c0204000
[00000000] *pgd=00000000
Internal error: Oops: 5 [#1] SMP ARM
Modules linked in:
CPU: 1 PID: 1 Comm: swapper/0 Tainted: G    B          3.19.0-rc3-00007-g412f9ba-dirty #840
Hardware name: Qualcomm (Flattened Device Tree)
task: ed948000 ti: ed944000 task.ti: ed944000
PC is at strlen+0xc/0x40
LR is at __create_file+0x64/0x1dc
pc : [<c04ee604>]    lr : [<c049f1c4>]    psr: 60000013
sp : ed945e40  ip : ed945e50  fp : ed945e4c
r10: 00000000  r9 : c1006094  r8 : 00000000
r7 : 000041ed  r6 : 00000000  r5 : ed4af998  r4 : c11b5e28
r3 : 00000000  r2 : ed945e38  r1 : a0000013  r0 : 00000000
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: 10c5787d  Table: 8020406a  DAC: 00000015
Process swapper/0 (pid: 1, stack limit = 0xed944248)
Stack: (0xed945e40 to 0xed946000)
5e40: ed945e7c ed945e50 c049f1c4 c04ee604 c0fc2fa4 00000000 ecb748c0 c11c2b80
5e60: c0beec04 0000011c c0fc2fa4 00000000 ed945e94 ed945e80 c049f3e0 c049f16c
5e80: 00000000 00000000 ed945eac ed945e98 c08cbc50 c049f3c0 ecb748c0 c11c2b80
5ea0: ed945ed4 ed945eb0 c0fc3080 c08cbc30 c0beec04 c107e1d8 ecdf0600 c107e1d8
5ec0: c107e1d8 ecdf0600 ed945f54 ed945ed8 c0208ed4 c0fc2fb0 c026a784 c04ee628
5ee0: ed945f0c ed945ef0 c0f5d600 c04ee604 c0f5d5ec ef7fcc7d c0b40ecc 0000011c
5f00: ed945f54 ed945f10 c026a994 c0f5d5f8 c04ecc00 00000007 ef7fcc95 00000007
5f20: c0e90744 c0dd0884 ed945f54 c106cde0 00000007 c117f8c0 0000011c c0f5d5ec
5f40: c1006094 c100609c ed945f94 ed945f58 c0f5de34 c0208e50 00000007 00000007
5f60: c0f5d5ec be9b5ae0 00000000 c117f8c0 c0af1680 00000000 00000000 00000000
5f80: 00000000 00000000 ed945fac ed945f98 c0af169c c0f5dd2c ed944000 00000000
5fa0: 00000000 ed945fb0 c020f298 c0af168c 00000000 00000000 00000000 00000000
5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 ebcc6d33 bfffca73
[<c04ee604>] (strlen) from [<c049f1c4>] (__create_file+0x64/0x1dc)
[<c049f1c4>] (__create_file) from [<c049f3e0>] (debugfs_create_dir+0x2c/0x34)
[<c049f3e0>] (debugfs_create_dir) from [<c08cbc50>] (clk_debug_create_one+0x2c/0x16c)
[<c08cbc50>] (clk_debug_create_one) from [<c0fc3080>] (clk_debug_init+0xdc/0x144)
[<c0fc3080>] (clk_debug_init) from [<c0208ed4>] (do_one_initcall+0x90/0x1e0)
[<c0208ed4>] (do_one_initcall) from [<c0f5de34>] (kernel_init_freeable+0x114/0x1e0)
[<c0f5de34>] (kernel_init_freeable) from [<c0af169c>] (kernel_init+0x1c/0xfc)
[<c0af169c>] (kernel_init) from [<c020f298>] (ret_from_fork+0x14/0x3c)
Code: c0b40ecc e1a0c00d e92dd800 e24cb004 (e5d02000)
---[ end trace b940e45b5e25c1e7 ]---

Fixes: 6314b6796e "clk: Don't hold prepare_lock across debugfs creation"
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Michael Turquette <mturquette@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2015-03-23 21:02:46 -04:00
..
accessibility printk: move braille console support into separate braille.[ch] files 2013-07-31 14:41:03 -07:00
acpi ACPI / LPSS: Deassert resets for SPI host controllers on Braswell 2015-03-06 14:52:49 -08:00
amba PM / Domains: Move dev_pm_domain_attach|detach() to pm_domain.h 2014-09-30 01:16:44 +02:00
ata ahci_xgene: Fix the endianess issue in APM X-Gene SoC AHCI SATA controller driver. 2015-01-29 17:40:45 -08:00
atm solos-pci: fix error return code 2014-11-23 14:29:44 -05:00
auxdisplay framebuffer: Use fb_<level> 2013-10-29 12:53:07 +02:00
base driver core: Fix unbalanced device reference in drivers_probe 2015-01-16 06:59:50 -08:00
bcma bcma: add another PCI ID of device with BCM43228 2014-10-23 14:02:06 -04:00
block rbd: fix rbd_dev_parent_get() when parent_overlap == 0 2015-02-05 22:36:04 -08:00
bluetooth Bluetooth: btusb: Add support for Lite-On (04ca) Broadcom based, BCM43142 2015-03-06 14:52:44 -08:00
bus bus: mvebu-mbus: fix support of MBus window 13 2015-01-29 17:40:44 -08:00
cdrom block,scsi: fixup blk_get_request dead queue scenarios 2014-08-28 10:03:46 -06:00
char Added Little Endian support to vtpm module 2015-03-06 14:52:58 -08:00
clk clk: Fix debugfs clk removal before inited 2015-03-23 21:02:46 -04:00
clocksource clocksource: mtk: Fix race conditions in probe code 2015-03-06 14:53:04 -08:00
connector connector: Use ktime_get_ns() 2014-07-23 10:18:07 -07:00
cpufreq cpufreq: s3c: remove last use of resume_clocks callback 2015-03-06 14:52:48 -08:00
cpuidle Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2014-10-24 12:48:47 -07:00
crypto crypto: prefix module autoloading with "crypto-" 2015-01-29 17:40:46 -08:00
dca dca: convert to idr_alloc() 2013-02-27 19:10:15 -08:00
devfreq PM / devfreq: exynos: Enable building exynos PPMU as module 2014-09-29 20:22:36 +09:00
dio m68k: don't export static inline functions 2009-12-06 11:18:28 +01:00
dma Merge branch 'fixes' of git://git.infradead.org/users/vkoul/slave-dma 2014-11-21 16:24:27 -08:00
dma-buf dma-buf: don't open-code atomic_long_read() 2014-10-09 02:39:07 -04:00
edac EDAC, amd64_edac: Prevent OOPS with >16 memory controllers 2015-03-06 14:53:05 -08:00
eisa Revert "EISA: Initialize device before its resources" 2014-01-17 14:57:29 -07:00
extcon extcon: gpio: Fix code cleanup 2014-09-22 16:48:47 +09:00
firewire firewire: cdev: prevent kernel stack leaking into ioctl arguments 2014-11-14 12:10:13 +01:00
firmware Merge branch 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2014-10-23 14:45:09 -07:00
fmc Merge 3.14-rc5 into char-misc-next 2014-03-02 19:53:09 -08:00
gpio gpio: tps65912: fix wrong container_of arguments 2015-03-06 14:53:03 -08:00
gpu drm/i915: Correct the IOSF Dev_FN field for IOSF transfers 2015-03-14 15:37:18 -04:00
hid HID: i2c-hid: Limit reads to wMaxInputLength bytes for input events 2015-03-06 14:52:46 -08:00
hsi HSI changes for the v3.17 series 2014-08-06 20:06:14 -07:00
hv Drivers: hv: vmbus: Fix a race condition when unregistering a device 2015-01-16 06:59:53 -08:00
hwmon hwmon: (g762) fix call to devm_hwmon_device_register_with_groups() 2014-11-19 14:06:47 -08:00
hwspinlock hwspinlock: enable OMAP build for AM33xx, AM43xx & DRA7xx 2014-07-29 11:46:28 +03:00
i2c i2c: s3c2410: fix ABBA deadlock by keeping clock prepared 2015-02-05 22:36:04 -08:00
ide Merge branch 'for-3.18/drivers' of git://git.kernel.dk/linux-block 2014-10-18 12:12:45 -07:00
idle intel_idle: Broadwell support 2014-08-15 17:06:40 -04:00
iio iio:adc:mcp3422 Fix incorrect scales table 2015-03-14 15:37:21 -04:00
infiniband IB/core: When marshaling ucma path from user-space, clear unused fields 2015-03-23 21:02:46 -04:00
input Input: i8042 - add noloop quirk for Medion Akoya E7225 (MD98857) 2015-02-05 22:36:04 -08:00
iommu iommu/vt-d: Fix dmar_domain leak in iommu_attach_device 2015-01-16 06:59:48 -08:00
ipack ipoctal: clear break interrupt as soon as it occurs 2014-09-23 23:26:42 -07:00
irqchip irqchip: atmel-aic-common: Prevent clobbering of priority when changing IRQ type 2015-01-29 17:40:45 -08:00
isdn isdn/gigaset: fix usb_gigaset write_cmd result race 2014-10-14 15:05:35 -04:00
leds leds: netxbig: fix oops at probe time 2015-01-27 08:29:40 -08:00
lguest mm/vmalloc.c: clean up map_vm_area third argument 2014-08-06 18:01:19 -07:00
macintosh powerpc: Move via-cuda symbol exports next to function definitions 2014-09-25 23:14:37 +10:00
mailbox Merge branch 'mailbox-for-linus' of git://git.linaro.org/landing-teams/working/fujitsu/integration 2014-10-21 11:21:19 -07:00
mcb mcb: Add support for shared PCI IRQs 2014-05-27 17:38:11 -07:00
md md/raid1: fix read balance when a drive is write-mostly. 2015-03-06 14:53:05 -08:00
media em28xx-audio: fix missing newlines, again 2015-03-06 14:52:52 -08:00
memory AT91 reset, poweroff and ram drivers 2014-08-25 15:35:26 +02:00
memstick memstick: r592: fix build warnings for !PM_SLEEP 2014-10-14 02:18:22 +02:00
message SCSI for-linus on 20141007 2014-10-07 21:29:18 -04:00
mfd mfd: rtsx_usb: Fix runtime PM deadlock 2015-01-29 17:40:42 -08:00
misc mei: make device disabled on stop unconditionally 2015-03-14 15:37:21 -04:00
mmc mmc: sdhci-pxav3: Fix Armada 38x controller's caps according to erratum ERR-7878951 2015-03-06 14:52:53 -08:00
mtd mtd: nand: omap: Fix NAND enumeration on 3430 LDP 2015-01-16 06:59:54 -08:00
net team: don't traverse port list using rcu in team_set_mac_address 2015-03-14 15:37:14 -04:00
nfc Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless 2014-10-07 14:48:29 -04:00
ntb ntb: Adding split BAR support for Haswell platforms 2014-10-17 07:08:51 -04:00
nubus kernel/printk: use symbolic defines for console loglevels 2014-06-04 16:54:17 -07:00
of of/fdt: memblock_reserve /memreserve/ regions in the case of partial overlap 2014-11-26 12:35:52 +00:00
oprofile drivers/oprofile: Replace __get_cpu_var uses for address calculation 2014-08-26 13:45:46 -04:00
parisc Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2014-10-13 16:23:15 +02:00
parport parport: parport_pc: Implement architecture and device check to cut off false-positives 2014-09-23 23:14:28 -07:00
pci PCI: Fix infinite loop with ROM image of size 0 2015-03-06 14:52:46 -08:00
pcmcia Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc 2014-08-07 08:50:34 -07:00
phy phy: omap-usb2: Enable runtime PM of omap-usb2 phy properly 2014-11-05 14:34:06 -08:00
pinctrl pinctrl: at91: allow to have disabled gpio bank 2015-02-05 22:36:06 -08:00
platform samsung-laptop: Add use_native_backlight quirk, and enable it on some models 2015-03-06 14:53:05 -08:00
pnp PNP: replace strnicmp with strncasecmp 2014-10-14 02:18:25 +02:00
power power: gpio-charger: balance enable/disable_irq_wake calls 2015-03-06 14:52:50 -08:00
powercap powercap / RAPL: change domain detection message 2014-09-03 01:29:00 +02:00
pps drivers/pps/clients/pps-gpio.c: remove redundant of_match_ptr 2013-11-13 12:09:35 +09:00
ps3 ps3-vuart: don't use PREPARE_WORK 2014-03-07 10:24:48 -05:00
ptp PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
pwm pwm: Changes for v3.18-rc1 2014-10-21 08:17:43 -07:00
rapidio PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
ras trace, RAS: Add eMCA trace event interface 2014-06-25 13:26:47 -07:00
regulator regulator: core: fix race condition in regulator_put() 2015-02-05 22:36:07 -08:00
remoteproc remoteproc: da8xx: don't select CMA on no-MMU 2014-06-17 17:09:36 +02:00
reset reset: sunxi: fix spinlock initialization 2015-01-27 08:29:41 -08:00
rpmsg A small pull request consisting of: 2013-05-07 14:02:00 -07:00
rtc drivers/rtc/rtc-s5m.c: terminate s5m_rtc_id array with empty element 2015-02-05 22:36:07 -08:00
s390 crypto: prefix module autoloading with "crypto-" 2015-01-29 17:40:46 -08:00
sbus Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc 2014-08-05 18:57:18 -07:00
scsi fixed invalid assignment of 64bit mask to host dma_boundary for scatter gather segment boundary limit. 2015-03-23 21:02:46 -04:00
sfi SFI / ACPI: Fix warnings reported during builds with W=1 2013-12-07 01:24:33 +01:00
sh drivers: sh: Leave disabling of unused PM domains to genpd 2014-09-09 00:46:13 +02:00
sn Drivers: misc: remove __dev* attributes. 2013-01-03 15:57:16 -08:00
soc soc: versatile: Add terminating entry for realview_soc_of_match 2014-10-28 22:05:07 +01:00
spi spi: imx: use pio mode for i.mx6dl 2015-02-11 15:00:51 +08:00
spmi spmi: Remove duplicate inclusion of module.h 2014-07-10 15:22:13 -07:00
ssb This is the bulk of GPIO changes for the v3.18 development 2014-10-09 14:58:15 -04:00
staging iio: mxs-lradc: only update the buffer when its conversions have finished 2015-03-14 15:37:20 -04:00
target target: Check for LBA + sectors wrap-around in sbc_parse_cdb 2015-03-14 15:37:19 -04:00
tc TC: Handle device_register() errors. 2014-06-26 10:48:23 +01:00
thermal tick/powerclamp: Remove tick_nohz_idle abuse 2015-01-27 08:29:37 -08:00
thunderbolt thunderbolt: Clear hops before overwriting 2014-08-26 14:54:48 -07:00
tty serial: 8250: Revert "tty: serial: 8250_core: read only RX if there is something in the FIFO" 2015-03-14 15:37:28 -04:00
uio uio: Export definition of struct uio_device 2014-10-02 21:35:54 -07:00
usb USB: serial: fix tty-device error handling at probe 2015-03-14 15:37:26 -04:00
uwb uwb: add an ASIE sysfs attribute to uwb_rc devices 2014-09-23 22:05:26 -07:00
vfio vfio-pci: Fix the check on pci device type in vfio_pci_probe() 2015-01-27 08:29:40 -08:00
vhost vhost-scsi: Add missing virtio-scsi -> TCM attribute conversion 2015-01-27 08:29:45 -08:00
video video/fbdev: fix defio's fsync 2015-01-27 08:29:39 -08:00
virt drivers: clean-up prom.h implicit includes 2013-10-09 20:04:04 -05:00
virtio One cc: stable commit, the rest are a series of minor cleanups which have 2014-10-18 10:25:09 -07:00
vlynq drivers/vlynq/vlynq.c: fix another resource size off by 1 error 2014-01-23 16:36:55 -08:00
vme vme: bridges: use pci_zalloc_consistent 2014-08-08 15:57:30 -07:00
w1 w1: select crc16 library for ds2406 2014-06-23 12:38:08 -04:00
watchdog watchdog: s3c2410_wdt: Fix the mask bit offset for Exynos7 2014-12-05 20:21:35 +01:00
xen xen-scsiback: mark pvscsi frontend request consumed only after last read 2015-03-06 14:52:49 -08:00
zorro zorro: Use ARRAY_SIZE 2014-07-11 10:38:02 +02:00
Kconfig soc: ti: add Keystone Navigator QMSS driver 2014-09-24 09:49:14 -04:00
Makefile Driver core patches for 3.17-rc1 2014-08-04 18:34:04 -07:00