linux-stable/drivers
Stephen Boyd f114a36246 clk: Evict unregistered clks from parent caches
commit bdcf1dc253 upstream.

We leave a dangling pointer in each clk_core::parents array that has an
unregistered clk as a potential parent when that clk_core pointer is
freed by clk{_hw}_unregister(). It is impossible for the true parent of
a clk to be set with clk_set_parent() once the dangling pointer is left
in the cache because we compare parent pointers in
clk_fetch_parent_index() instead of checking for a matching clk name or
clk_hw pointer.

Before commit ede7785847 ("clk: Remove global clk traversal on fetch
parent index"), we would check clk_hw pointers, which has a higher
chance of being the same between registration and unregistration, but it
can still be allocated and freed by the clk provider. In fact, this has
been a long standing problem since commit da0f0b2c3a ("clk: Correct
lookup logic in clk_fetch_parent_index()") where we stopped trying to
compare clk names and skipped over entries in the cache that weren't
NULL.

There are good (performance) reasons to not do the global tree lookup in
cases where the cache holds dangling pointers to parents that have been
unregistered. Let's take the performance hit on the uncommon
registration path instead. Loop through all the clk_core::parents arrays
when a clk is unregistered and set the entry to NULL when the parent
cache entry and clk being unregistered are the same pointer. This will
fix this problem and avoid the overhead for the "normal" case.

Based on a patch by Bjorn Andersson.

Fixes: da0f0b2c3a ("clk: Correct lookup logic in clk_fetch_parent_index()")
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Tested-by: Sai Prakash Ranjan <saiprakash.ranjan@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lkml.kernel.org/r/20190828181959.204401-1-sboyd@kernel.org
Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-26 10:30:00 +02:00
..
accessibility
acpi ACPICA: Do not increment operation_region reference counts for field units 2020-08-21 09:48:06 +02:00
amba
android binder: Prevent context manager from incrementing ref 0 2020-08-21 09:47:58 +02:00
ata ata/libata: Fix usage of page address by page_address in ata_scsi_mode_select_xlat function 2020-06-30 15:38:06 -04:00
atm atm: fix atm_dev refcnt leaks in atmtcp_remove_persistent 2020-08-21 09:48:00 +02:00
auxdisplay
base regmap: debugfs: check count when read regmap file 2020-07-31 16:44:45 +02:00
bcma bcma: fix incorrect update of BCMA_CORE_PCI_MDIO_DATA 2020-01-27 14:46:45 +01:00
block Revert "zram: convert remaining CLASS_ATTR() to CLASS_ATTR_RO()" 2020-07-22 09:22:27 +02:00
bluetooth Bluetooth: hci_serdev: Only unregister device if it was registered 2020-08-21 09:48:11 +02:00
bus bus: sunxi-rsb: Return correct data when mixing 16-bit and 8-bit reads 2020-04-24 08:00:23 +02:00
cdrom cdrom: respect device capabilities during opening action 2020-01-04 13:59:52 +01:00
char agp/intel: Fix a memory leak on module initialisation failure 2020-08-21 09:48:06 +02:00
clk clk: Evict unregistered clks from parent caches 2020-08-26 10:30:00 +02:00
clocksource clocksource: dw_apb_timer_of: Fix missing clockevent timers 2020-06-20 10:25:08 +02:00
connector
cpufreq cpufreq: intel_pstate: Fix cpuinfo_max_freq when MSR_TURBO_RATIO_LIMIT is 0 2020-08-26 10:29:56 +02:00
cpuidle cpuidle: Fix three reference count leaks 2020-06-20 10:25:14 +02:00
crypto crypto: cpt - don't sleep of CRYPTO_TFM_REQ_MAY_SLEEP was not specified 2020-08-21 09:48:14 +02:00
dax
dca
devfreq Revert "PM / devfreq: Modify the device name as devfreq(X) for sysfs" 2020-03-11 18:02:50 +01:00
dio
dma dmaengine: ioat setting ioat timeout as module parameter 2020-07-29 07:42:55 +02:00
dma-buf
edac EDAC: Fix reference count leaks 2020-08-21 09:48:03 +02:00
eisa
extcon extcon: adc-jack: Fix an error handling path in 'adc_jack_probe()' 2020-06-25 15:41:55 +02:00
firewire net: add annotations on hh->hh_len lockless accesses 2020-01-09 10:17:59 +01:00
firmware efi: Make it possible to disable efivar_ssdt entirely 2020-07-09 09:36:33 +02:00
fmc
fpga
fsi fsi: core: Fix small accesses and unaligned offsets via sysfs 2019-12-31 12:37:35 +01:00
gpio gpio: arizona: put pm_runtime in case of failure 2020-07-29 07:42:51 +02:00
gpu drm/vgem: Replace opencoded version of drm_gem_dumb_map_offset() 2020-08-26 10:29:53 +02:00
hid HID: input: Fix devices that return multiple bytes in battery report 2020-08-21 09:48:02 +02:00
hsi
hv Drivers: hv: vmbus: Ignore CHANNELMSG_TL_CONNECT_RESULT(23) 2020-08-21 09:48:00 +02:00
hwmon hwmon: (aspeed-pwm-tacho) Avoid possible buffer overflow 2020-07-29 07:42:55 +02:00
hwspinlock
hwtracing coresight: tmc: Fix TMC mode read in tmc_read_unprepare_etb() 2020-08-21 09:48:10 +02:00
i2c i2c: rcar: avoid race when unregistering slave 2020-08-21 09:48:21 +02:00
ide ide: serverworks: potential overflow in svwks_set_pio_mode() 2020-02-28 16:36:05 +01:00
idle
iio iio: dac: ad5592r: fix unbalanced mutex unlocks in ad5592r_read_raw() 2020-08-21 09:48:17 +02:00
infiniband RDMA/ipoib: Return void from ipoib_ib_dev_stop() 2020-08-21 09:48:20 +02:00
input Input: psmouse - add a newline when printing 'proto' by sysfs 2020-08-26 10:29:56 +02:00
iommu iommu/omap: Check for failure of a call to omap_iommu_dump_ctx 2020-08-21 09:48:21 +02:00
ipack
irqchip genirq/affinity: Make affinity setting if activated opt-in 2020-08-21 09:48:23 +02:00
isdn
leds leds: core: Flush scheduled work for system suspend 2020-08-21 09:48:09 +02:00
lightnvm lightnvm: pblk: fix lock order in pblk_rb_tear_down_check 2020-01-27 14:46:32 +01:00
macintosh drivers/macintosh: Fix memleak in windfarm_pm112 driver 2020-06-20 10:25:19 +02:00
mailbox
mcb
md dm cache: remove all obsolete writethrough-specific code 2020-08-21 09:48:24 +02:00
media media: vpss: clean up resources in init 2020-08-26 10:29:56 +02:00
memory
memstick
message scsi: mptscsih: Fix read sense data size 2020-07-22 09:22:16 +02:00
mfd mfd: dln2: Run event handler loop under spinlock 2020-08-21 09:48:22 +02:00
misc cxl: Fix kobject memleak 2020-08-21 09:48:08 +02:00
mmc mmc: sdhci: do not enable card detect interrupt for gpio cd type 2020-07-22 09:22:23 +02:00
mtd mtd: rawnand: qcom: avoid write to unavailable register 2020-08-21 09:48:15 +02:00
mux
net net: dsa: b53: check for timeout 2020-08-26 10:29:59 +02:00
nfc nfc: s3fwrn5: add missing release on skb in s3fwrn5_recv_frame 2020-08-05 10:06:52 +02:00
ntb NTB: Fix the default port and peer numbers for legacy drivers 2020-06-25 15:41:50 +02:00
nubus
nvdimm libnvdimm: Fix endian conversion issues 2020-06-11 09:22:55 +02:00
nvme nvme-rdma: assign completion vector correctly 2020-07-22 09:22:16 +02:00
nvmem nvmem: qfprom: remove incorrect write support 2020-06-11 09:23:01 +02:00
of of: of_mdio: Correct loop scanning logic 2020-07-22 09:22:23 +02:00
oprofile
parisc parisc: mask out enable and reserved bits from sba imask 2020-08-21 09:48:16 +02:00
parport parport: load lowlevel driver if ports not found 2019-12-31 12:37:39 +01:00
pci PCI: hotplug: ACPI: Fix context refcounting in acpiphp_grab_context() 2020-08-21 09:48:17 +02:00
pcmcia
perf drivers/perf: arm_pmu_acpi: Fix incorrect checking of gicc pointer 2020-04-02 16:34:14 +02:00
phy phy: sun4i-usb: fix dereference of pointer phy0 before it is null checked 2020-07-22 09:22:24 +02:00
pinctrl pinctrl-single: fix pcs_parse_pinconf() return value 2020-08-21 09:48:13 +02:00
platform platform/x86: intel-vbtn: Fix return value check in check_acpi_dev() 2020-08-21 09:48:03 +02:00
pnp
power power: supply: check if calc_soc succeeded in pm860x_init_battery 2020-08-21 09:48:11 +02:00
powercap
pps
ps3
ptp ptp: free ptp device pin descriptors properly 2020-01-23 08:20:35 +01:00
pwm pwm: bcm-iproc: handle clk_get_rate() return 2020-08-21 09:48:21 +02:00
rapidio rapidio: fix an error in get_user_pages_fast() error handling 2020-05-27 16:43:12 +02:00
ras
regulator regulator: rk808: Lower log level on optional GPIOs being not available 2020-02-28 16:35:59 +01:00
remoteproc remoteproc: Fix IDR initialisation in rproc_alloc() 2020-06-25 15:41:47 +02:00
reset
rpmsg rpmsg: glink: smem: Ensure ordering during tx 2020-04-24 08:01:06 +02:00
rtc rtc: goldfish: Enable interrupt in set_alarm() when necessary 2020-08-26 10:29:55 +02:00
s390 s390/qeth: don't process empty bridge port events 2020-08-21 09:48:11 +02:00
sbus
scsi scsi: libfc: Free skb in fc_disc_gpn_id_resp() for valid cases 2020-08-26 10:29:56 +02:00
sfi
sh
sn
soc soc: imx: gpc: fix power up sequencing 2020-04-24 08:01:18 +02:00
spi spi: Prevent adding devices below an unregistering controller 2020-08-26 10:29:55 +02:00
spmi
ssb
staging staging: rtl8192u: fix a dubious looking mask before a shift 2020-08-21 09:48:09 +02:00
target scsi: target/iblock: fix WRITE SAME zeroing 2020-05-05 19:15:52 +02:00
tc
tee tee: optee: Fix compilation issue with nommu 2020-02-05 14:18:24 +00:00
thermal thermal: ti-soc-thermal: Fix reversed condition in ti_thermal_expose_sensor() 2020-08-21 09:48:10 +02:00
thunderbolt thunderbolt: Prevent crash if non-active NVMem file is read 2020-02-28 16:36:09 +01:00
tty vt: Reject zero-sized screen buffer size. 2020-07-29 07:42:57 +02:00
uio uio_pdrv_genirq: fix use without device tree and no interrupt 2020-07-22 09:22:27 +02:00
usb USB: serial: ftdi_sio: clean up receive processing 2020-08-21 09:48:20 +02:00
uwb
vfio vfio/type1: Add proper error unwind for vfio_iommu_replay() 2020-08-26 10:29:59 +02:00
vhost vhost/vsock: fix packet delivery order to monitoring devices 2020-05-27 16:42:56 +02:00
video video: pxafb: Fix the function used to balance a 'dma_alloc_coherent()' call 2020-08-21 09:48:07 +02:00
virt
virtio virtio_ring: Avoid loop when vq is broken in virtqueue_poll 2020-08-26 10:29:57 +02:00
vlynq
vme vme: bridges: reduce stack usage 2020-02-28 16:36:04 +01:00
w1 w1: omap-hdq: cleanup to add missing newline for some dev_dbg 2020-06-20 10:25:20 +02:00
watchdog watchdog: f71808e_wdt: clear watchdog timeout occurred flag 2020-08-21 09:48:19 +02:00
xen xen: don't reschedule in preemption off sections 2020-08-26 10:30:00 +02:00
zorro
Kconfig
Makefile