android_kernel_oneplus_msm8998/drivers
Lars-Peter Clausen b19f9c4311 iio: adis_lib: Initialize trigger before requesting interrupt
commit f027e0b3a774e10302207e91d304bbf99e3a8b36 upstream.

The adis_probe_trigger() creates a new IIO trigger and requests an
interrupt associated with the trigger. The interrupt uses the generic
iio_trigger_generic_data_rdy_poll() function as its interrupt handler.

Currently the driver initializes some fields of the trigger structure after
the interrupt has been requested. But an interrupt can fire as soon as it
has been requested. This opens up a race condition.

iio_trigger_generic_data_rdy_poll() will access the trigger data structure
and dereference the ops field. If the ops field is not yet initialized this
will result in a NULL pointer deref.

It is not expected that the device generates an interrupt at this point, so
typically this issue did not surface unless e.g. due to a hardware
misconfiguration (wrong interrupt number, wrong polarity, etc.).

But some newer devices from the ADIS family start to generate periodic
interrupts in their power-on reset configuration and unfortunately the
interrupt can not be masked in the device.  This makes the race condition
much more visible and the following crash has been observed occasionally
when booting a system using the ADIS16460.

	Unable to handle kernel NULL pointer dereference at virtual address 00000008
	pgd = c0004000
	[00000008] *pgd=00000000
	Internal error: Oops: 5 [#1] PREEMPT SMP ARM
	Modules linked in:
	CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.9.0-04126-gf9739f0-dirty #257
	Hardware name: Xilinx Zynq Platform
	task: ef04f640 task.stack: ef050000
	PC is at iio_trigger_notify_done+0x30/0x68
	LR is at iio_trigger_generic_data_rdy_poll+0x18/0x20
	pc : [<c042d868>]    lr : [<c042d924>]    psr: 60000193
	sp : ef051bb8  ip : 00000000  fp : ef106400
	r10: c081d80a  r9 : ef3bfa00  r8 : 00000087
	r7 : ef051bec  r6 : 00000000  r5 : ef3bfa00  r4 : ee92ab00
	r3 : 00000000  r2 : 00000000  r1 : 00000000  r0 : ee97e400
	Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment none
	Control: 18c5387d  Table: 0000404a  DAC: 00000051
	Process swapper/0 (pid: 1, stack limit = 0xef050210)
	[<c042d868>] (iio_trigger_notify_done) from [<c0065b10>] (__handle_irq_event_percpu+0x88/0x118)
	[<c0065b10>] (__handle_irq_event_percpu) from [<c0065bbc>] (handle_irq_event_percpu+0x1c/0x58)
	[<c0065bbc>] (handle_irq_event_percpu) from [<c0065c30>] (handle_irq_event+0x38/0x5c)
	[<c0065c30>] (handle_irq_event) from [<c0068e28>] (handle_level_irq+0xa4/0x130)
	[<c0068e28>] (handle_level_irq) from [<c0064e74>] (generic_handle_irq+0x24/0x34)
	[<c0064e74>] (generic_handle_irq) from [<c021ab7c>] (zynq_gpio_irqhandler+0xb8/0x13c)
	[<c021ab7c>] (zynq_gpio_irqhandler) from [<c0064e74>] (generic_handle_irq+0x24/0x34)
	[<c0064e74>] (generic_handle_irq) from [<c0065370>] (__handle_domain_irq+0x5c/0xb4)
	[<c0065370>] (__handle_domain_irq) from [<c000940c>] (gic_handle_irq+0x48/0x8c)
	[<c000940c>] (gic_handle_irq) from [<c0013e8c>] (__irq_svc+0x6c/0xa8)

To fix this make sure that the trigger is fully initialized before
requesting the interrupt.

Fixes: ccd2b52f4a ("staging:iio: Add common ADIS library")
Reported-by: Robin Getz <Robin.Getz@analog.com>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-28 10:17:22 +01:00
..
accessibility
acpi ACPI: sbshc: remove raw pointer from printk() message 2018-02-16 20:09:47 +01:00
amba
android binder: check for binder_thread allocation failure in binder_poll() 2018-02-25 11:03:38 +01:00
ata ahci: Add Intel Cannon Lake PCH-H PCI ID 2018-02-16 20:09:42 +01:00
atm atm: horizon: Fix irq release error 2017-12-16 10:33:55 +01:00
auxdisplay
base drivers: base: cacheinfo: fix boot error message when acpi is enabled 2018-01-31 12:06:08 +01:00
bcma bcma: use (get|put)_device when probing/removing device driver 2017-03-12 06:37:30 +01:00
block pktcdvd: Fix pkt_setup_dev() error path 2018-02-16 20:09:47 +01:00
bluetooth Bluetooth: btusb: Restore QCA Rome suspend/resume fix with a "rewritten" version 2018-02-16 20:09:46 +01:00
bus sunxi-rsb: Include OF based modalias in device uevent 2018-01-10 09:27:09 +01:00
cdrom
char hwrng: exynos - use __maybe_unused to hide pm functions 2018-02-25 11:03:47 +01:00
clk clk: tegra: Fix cclk_lp divisor register 2017-12-20 10:04:59 +01:00
clocksource clockevents/drivers/cs5535: Improve resilience to spurious interrupts 2017-10-27 10:23:17 +02:00
connector
cpufreq cpufreq: Add Loongson machine dependencies 2018-02-03 17:04:27 +01:00
cpuidle cpuidle: fix broadcast control when broadcast can not be entered 2017-12-25 14:22:15 +01:00
crypto crypto: s5p-sss - Fix kernel Oops in AES-ECB mode 2018-02-25 11:03:55 +01:00
dca
devfreq PM / devfreq: Propagate error from devfreq_add_device() 2018-02-22 15:44:58 +01:00
dio
dma dmaengine: zx: fix build warning 2018-02-25 11:03:50 +01:00
dma-buf
edac EDAC, octeon: Fix an uninitialized variable warning 2018-02-16 20:09:47 +01:00
eisa
extcon extcon: palmas: Check the parent instance to prevent the NULL 2017-11-21 09:21:18 +01:00
firewire firewire: net: fix fragmented datagram_size off-by-one 2016-11-10 16:36:35 +01:00
firmware efi/esrt: Cleanup bad memory map log messages 2017-12-20 10:04:56 +01:00
fmc
fpga
gpio gpio: xgene: mark PM functions as __maybe_unused 2018-02-25 11:03:50 +01:00
gpu drm/gma500: remove helper function 2018-02-25 11:03:52 +01:00
hid HID: quirks: Fix keyboard + touchpad on Toshiba Click Mini not working 2018-02-16 20:09:46 +01:00
hsi
hv Drivers: hv: vmbus: fix build warning 2018-02-25 11:03:46 +01:00
hwmon hwmon: (pmbus) Use 64bit math for DIRECT format values 2018-02-03 17:04:28 +01:00
hwspinlock
hwtracing intel_th: pci: Add Gemini Lake support 2017-12-20 10:04:54 +01:00
i2c i2c: remove __init from i2c_register_board_info() 2018-02-25 11:03:48 +01:00
ide
idle idle: i7300: add PCI dependency 2018-02-25 11:03:51 +01:00
iio iio: adis_lib: Initialize trigger before requesting interrupt 2018-02-28 10:17:22 +01:00
infiniband infiniband: cxgb4: use %pR format string for printing resources 2018-02-25 11:03:48 +01:00
input Input: tca8418_keypad - hide gcc-4.9 -Wmaybe-uninitialized warning 2018-02-25 11:03:49 +01:00
iommu iommu/arm-smmu-v3: Don't free page table ops twice 2018-01-17 09:35:25 +01:00
ipack
irqchip irqchip/crossbar: Fix incorrect type of register size 2017-12-16 10:33:52 +01:00
isdn isdn: sc: work around type mismatch warning 2018-02-25 11:03:51 +01:00
leds leds: ktd2692: avoid harmless maybe-uninitialized warning 2017-05-14 13:32:55 +02:00
lguest
lightnvm lightnvm: put bio before return 2016-09-24 10:07:35 +02:00
macintosh
mailbox mailbox: handle empty message in tx_tick 2017-08-06 19:19:41 -07:00
mcb
md md: avoid warning for 32-bit sector_t 2018-02-25 11:03:44 +01:00
media v4l: remove MEDIA_TUNER dependency for VIDEO_TUNER 2018-02-25 11:03:50 +01:00
memory ARM: OMAP2+: gpmc-onenand: propagate error on initialization failure 2017-12-16 10:33:51 +01:00
memstick memstick: rtsx_usb_ms: Manage runtime PM when accessing the device 2016-10-28 03:01:35 -04:00
message mptfusion: hide unused seq_mpt_print_ioc_summary function 2018-02-25 11:03:45 +01:00
mfd mfd: twl6040: Fix child-node lookup 2018-01-02 20:33:20 +01:00
misc cxl: Check if vphb exists before iterating over AFU devices 2017-12-25 14:22:08 +01:00
mmc mmc: sdhci-of-esdhc: add/remove some quirks according to vendor version 2018-01-31 12:06:09 +01:00
mtd mtd: cfi: enforce valid geometry configuration 2018-02-25 11:03:46 +01:00
net net: hp100: remove unnecessary #ifdefs 2018-02-25 11:03:50 +01:00
nfc nfc: fdp: fix NULL pointer dereference 2017-08-06 19:19:40 -07:00
ntb ntb_transport: fix bug calculating num_qps_mw 2017-08-30 10:19:29 +02:00
nubus
nvdimm libnvdimm, namespace: make 'resource' attribute only readable by root 2017-11-30 08:37:23 +00:00
nvme nvme: Fix managing degraded controllers 2018-02-16 20:09:47 +01:00
nvmem nvmem: imx-ocotp: Fix wrong register size 2017-08-06 19:19:46 -07:00
of of: device: Export of_device_{get_modalias, uvent_modalias} to modules 2017-07-27 15:06:09 -07:00
oprofile
parisc parisc: Hide Diva-built-in serial aux and graphics card 2018-01-02 20:33:20 +01:00
parport parisc, parport_gsc: Fixes for printk continuation lines 2017-06-17 06:39:37 +02:00
pci PCI: keystone: Fix interrupt-controller-node lookup 2018-02-28 10:17:21 +01:00
pcmcia
perf drivers/perf: arm_pmu: Fix leak in error path 2016-10-07 15:23:41 +02:00
phy phy: work around 'phys' references to usb-nop-xceiv devices 2018-01-23 19:50:16 +01:00
pinctrl pinctrl: sunxi: Fix A80 interrupt pin bank 2018-02-25 11:03:39 +01:00
platform dell-wmi, dell-laptop: depends DMI 2018-02-25 11:03:51 +01:00
pnp
power power: bq27xxx_battery: mark some symbols __maybe_unused 2018-02-25 11:03:50 +01:00
powercap
pps
ps3
ptp
pwm pwm: pca9685: Fix period change with same duty cycle 2017-03-15 09:57:14 +08:00
rapidio
ras
regulator regulator: fan53555: fix I2C device ids 2017-11-02 09:40:50 +01:00
remoteproc
reset
rpmsg
rtc rtc-opal: Fix handling of firmware error codes, prevent busy loops 2018-02-22 15:44:59 +01:00
s390 s390/dasd: prevent prefix I/O error 2018-02-25 11:03:40 +01:00
sbus
scsi scsi: ibmvfc: fix misdefined reserved field in ibmvfc_fcp_rsp_info 2018-02-28 10:17:22 +01:00
sfi
sh
sn
soc soc: qcom/spm: shut up uninitialized variable warning 2016-09-24 10:07:42 +02:00
spi spi: sun4i: disable clocks in the remove function 2018-02-25 11:03:41 +01:00
spmi spmi: Include OF based modalias in device uevent 2017-07-27 15:06:10 -07:00
ssb ssb: mark ssb_bus_register as __maybe_unused 2018-02-25 11:03:44 +01:00
staging staging: unisys: visorinput depends on INPUT 2018-02-25 11:03:48 +01:00
target target/user: Fix cast from pointer to phys_addr_t 2018-02-25 11:03:46 +01:00
tc
thermal thermal: spear: use __maybe_unused for PM functions 2018-02-25 11:03:44 +01:00
thunderbolt
tty serial: 8250_mid: fix broken DMA dependency 2018-02-25 11:03:49 +01:00
uio uio: fix dmem_region_start computation 2016-10-31 04:13:59 -06:00
usb ARM: tegra: select USB_ULPI from EHCI rather than platform 2018-02-25 11:03:51 +01:00
uwb uwb: ensure that endpoint is interrupt 2017-10-12 11:27:35 +02:00
vfio vfio-pci: Handle error from pci_iomap 2017-08-06 19:19:46 -07:00
vhost vhost_net: stop device during reset owner 2018-02-16 20:09:38 +01:00
video fbdev: sm712fb: avoid unused function warnings 2018-02-25 11:03:47 +01:00
virt
virtio virtio_balloon: prevent uninitialized variable use 2018-02-25 11:03:42 +01:00
vlynq
vme vme: Fix wrong pointer utilization in ca91cx42_slave_get 2017-01-19 20:17:21 +01:00
w1 w1: ds2490: USB transfer buffers need to be DMAable 2017-03-12 06:37:29 +01:00
watchdog watchdog: imx2_wdt: restore previous timeout after suspend+resume 2018-02-16 20:09:45 +01:00
xen xen: XEN_ACPI_PROCESSOR is Dom0-only 2018-02-25 11:03:41 +01:00
zorro
Kconfig
Makefile usb: build drivers/usb/common/ when USB_SUPPORT is set 2018-02-25 11:03:38 +01:00