kernel-ark/drivers/staging
Lars-Peter Clausen e10554738c staging:iio:ade7758: Fix NULL pointer deref when enabling buffer
In older versions of the IIO framework it was possible to pass a completely
different set of channels to iio_buffer_register() as the one that is
assigned to the IIO device. Commit 959d2952d1 ("staging:iio: make
iio_sw_buffer_preenable much more general.") introduced a restriction that
requires that the set of channels that is passed to iio_buffer_register() is
a subset of the channels assigned to the IIO device as the IIO core will use
the list of channels that is assigned to the device to lookup a channel by
scan index in iio_compute_scan_bytes(). If it can not find the channel the
function will crash. This patch fixes the issue by making sure that the same
set of channels is assigned to the IIO device and passed to
iio_buffer_register().

Note that we need to remove the IIO_CHAN_INFO_RAW and IIO_CHAN_INFO_SCALE
info attributes from the channels since we don't actually want those to be
registered.

Fixes the following crash:
	Unable to handle kernel NULL pointer dereference at virtual address 00000016
	pgd = d2094000
	[00000016] *pgd=16e39831, *pte=00000000, *ppte=00000000
	Internal error: Oops: 17 [#1] PREEMPT SMP ARM
	Modules linked in:
	CPU: 1 PID: 1695 Comm: bash Not tainted 3.17.0-06329-g29461ee #9686
	task: d7768040 ti: d5bd4000 task.ti: d5bd4000
	PC is at iio_compute_scan_bytes+0x38/0xc0
	LR is at iio_compute_scan_bytes+0x34/0xc0
	pc : [<c0316de8>]    lr : [<c0316de4>]    psr: 60070013
	sp : d5bd5ec0  ip : 00000000  fp : 00000000
	r10: d769f934  r9 : 00000000  r8 : 00000001
	r7 : 00000000  r6 : c8fc6240  r5 : d769f800  r4 : 00000000
	r3 : d769f800  r2 : 00000000  r1 : ffffffff  r0 : 00000000
	Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
	Control: 18c5387d  Table: 1209404a  DAC: 00000015
	Process bash (pid: 1695, stack limit = 0xd5bd4240)
	Stack: (0xd5bd5ec0 to 0xd5bd6000)
	5ec0: d769f800 d7435640 c8fc6240 d769f984 00000000 c03175a4 d7435690 d7435640
	5ee0: d769f990 00000002 00000000 d769f800 d5bd4000 00000000 000b43a8 c03177f4
	5f00: d769f810 0162b8c8 00000002 c8fc7e00 d77f1d08 d77f1da8 c8fc7e00 c01faf1c
	5f20: 00000002 c010694c c010690c d5bd5f88 00000002 c8fc6840 c8fc684c c0105e08
	5f40: 00000000 00000000 d20d1580 00000002 000af408 d5bd5f88 c000de84 c00b76d4
	5f60: d20d1580 000af408 00000002 d20d1580 d20d1580 00000002 000af408 c000de84
	5f80: 00000000 c00b7a44 00000000 00000000 00000002 b6ebea78 00000002 000af408
	5fa0: 00000004 c000dd00 b6ebea78 00000002 00000001 000af408 00000002 00000000
	5fc0: b6ebea78 00000002 000af408 00000004 bee96a4c 000a6094 00000000 000b43a8
	5fe0: 00000000 bee969cc b6e2eb77 b6e6525c 40070010 00000001 00000000 00000000
	[<c0316de8>] (iio_compute_scan_bytes) from [<c03175a4>] (__iio_update_buffers+0x248/0x438)
	[<c03175a4>] (__iio_update_buffers) from [<c03177f4>] (iio_buffer_store_enable+0x60/0x7c)
	[<c03177f4>] (iio_buffer_store_enable) from [<c01faf1c>] (dev_attr_store+0x18/0x24)
	[<c01faf1c>] (dev_attr_store) from [<c010694c>] (sysfs_kf_write+0x40/0x4c)
	[<c010694c>] (sysfs_kf_write) from [<c0105e08>] (kernfs_fop_write+0x110/0x154)
	[<c0105e08>] (kernfs_fop_write) from [<c00b76d4>] (vfs_write+0xbc/0x170)
	[<c00b76d4>] (vfs_write) from [<c00b7a44>] (SyS_write+0x40/0x78)
	[<c00b7a44>] (SyS_write) from [<c000dd00>] (ret_fast_syscall+0x0/0x30)

Fixes: 959d2952d1 ("staging:iio: make iio_sw_buffer_preenable much more general.")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-11-05 18:33:47 +00:00
..
android Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2014-10-13 11:28:42 +02:00
bcm Staging: bcm: Removed unnecessary else. 2014-10-02 09:33:46 -07:00
board
comedi drivers/staging/comedi/Kconfig: Let COMEDI_II_PCI20KC depend on HAS_IOMEM 2014-10-20 10:56:17 +08:00
cptm1217
dgap staging: dgap: use dgap_release_remap() in dgap_cleanup_board() 2014-09-23 23:39:25 -07:00
dgnc TTY/Serial driver patches for 3.18-rc1 2014-10-08 06:52:11 -04:00
emxx_udc staging: emxx_udc: Use min_t instead of min 2014-10-02 13:51:03 -07:00
ft1000 staging: ft1000: ft1000-usb: Removed unnecessary else statement. 2014-10-02 10:13:37 -07:00
fwserial
gdm72xx drivers: staging: gdm72xx: Removed unnecessary braces. 2014-09-28 23:27:35 -04:00
gdm724x staging: gdm724x: Removed unnecessary else expression. 2014-09-28 23:27:34 -04:00
goldfish staging: goldfish: avoid multiple assignments 2014-09-06 21:54:57 -07:00
gs_fpgaboot staging: gs_fpgaboot Fix trailing whitespace. 2014-09-19 17:42:15 -07:00
iio staging:iio:ade7758: Fix NULL pointer deref when enabling buffer 2014-11-05 18:33:47 +00:00
imx-drm Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2014-10-14 09:39:08 +02:00
line6 staging: line6: fix midibuf.c coding style issue 2014-09-23 23:41:25 -07:00
lustre 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
media media updates for v3.18-rc1 2014-10-10 22:04:49 -04:00
mt29f_spinand staging/mt29f_spinand: coding style fixes 2014-08-16 12:23:27 -07:00
netlogic staging: netlogic: fix checkpatch.pl "LINE_SPACING" issuses 2014-09-08 14:02:13 -07:00
nvec staging/nvec: Use platform_get_irq() 2014-07-30 17:18:47 -07:00
octeon staging: octeon: Combined seperate strings. 2014-10-02 09:59:20 -07:00
octeon-usb Staging: octeon-hcd: removed dummy label 2014-09-11 14:49:13 -07:00
olpc_dcon
ozwpan staging: ozwpan: Remove typedefs 2014-09-28 22:03:58 -04:00
panel
rtl8188eu staging: r8188eu: replace strnicmp with strncasecmp 2014-10-14 02:18:25 +02:00
rtl8192e staging: rtl8192e: use %*pEn to escape buffer 2014-10-14 02:18:27 +02:00
rtl8192u staging: rtl8192u: use %*pEn to escape buffer 2014-10-14 02:18:27 +02:00
rtl8712 staging: rtl8712: Fixed else not required after return 2014-10-02 11:59:40 -07:00
rtl8723au staging: rtl8723au: Fix alignment of mac_addr for ether_addr_copy() usage 2014-10-20 12:51:10 +08:00
rts5208 staging: rts5208: remove unnecessary else 2014-10-02 10:07:04 -07:00
skein staging: skein: replace spaces with tabs 2014-09-19 17:27:28 -07:00
slicoss staging: slicoss: Fix void function return statements style warning 2014-09-28 23:36:24 -04:00
speakup staging: speakup: Fixed warning <linux/serial.h> instead of <asm/serial.h> 2014-10-02 10:09:01 -07:00
ste_rmi4 Staging: ste_rmi4: add new line after declarations 2014-09-23 13:44:11 -07:00
unisys staging: unisys: Fix CamelCase in uislib_force_channel_interrupt() 2014-10-02 09:49:29 -07:00
vme Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2014-10-13 11:28:42 +02:00
vt6655 staging: vt6655: Fixed C99 // comment errors in wpactl.c 2014-10-02 10:11:26 -07:00
vt6656 staging: vt6656: Merge three lines into one 2014-09-28 23:22:21 -04:00
wlan-ng staging: wlan-ng: use %*pEhp to print SN 2014-10-14 02:18:27 +02:00
xgifb staging: xgifb: remove unnecessary else 2014-09-06 21:48:19 -07:00
Kconfig staging: et131x: Remove et131x driver from drivers/staging 2014-10-03 13:55:14 -07:00
Makefile staging: et131x: Remove et131x driver from drivers/staging 2014-10-03 13:55:14 -07:00
staging.c