linux/drivers/misc
Éric Piel 1510dd5954 lis3lv02d: avoid divide by zero due to unchecked
After an "unexpected" reboot, I found this Oops in my logs:

divide error: 0000 [#1] PREEMPT SMP=20
CPU 0=20
Modules linked in: lis3lv02d hp_wmi input_polldev [...]
Pid: 390, comm: modprobe Tainted: G         C  2.6.39-rc7-wl+=20
RIP: 0010:[<ffffffffa014b427>]  [<ffffffffa014b427>]
		 lis3lv02d_poweron+0x4e/0x94 [lis3lv02d]
RSP: 0018:ffff8801d6407cf8  EFLAGS: 00010246
RAX: 0000000000000bb8 RBX: ffffffffa014e000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffea00066e4708 RDI: ffff8801df002700
RBP: ffff8801d6407d18 R08: ffffea00066c5a30 R09: ffffffff812498c9
R10: ffff8801d7bfcea0 R11: ffff8801d7bfce10 R12: 0000000000000bb8
R13: 00000000ffffffda R14: ffffffffa0154120 R15: ffffffffa0154030
=46S:  00007fc0705db700(0000) GS:ffff8801dfa00000(0000) knlGS:0
CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 00007f33549174f0 CR3: 00000001d65c9000 CR4: 00000000000406f0
Process modprobe (pid: 390, threadinfo ffff8801d6406000, task ffff8801d6b40=
000)
Stack:
 ffffffffa0154120 62ffffffa0154030 ffffffffa014e000 00000000ffffffea
 ffff8801d6407d58 ffffffffa014bcc1 0000000000000000 0000000000000048
 ffff8801d8bae800 00000000ffffffea 00000000ffffffda ffffffffa0154120
Call Trace:
 [<ffffffffa014bcc1>] lis3lv02d_init_device+0x1ce/0x496 [lis3lv02d]
 [<ffffffffa01522ff>] lis3lv02d_add+0x10f/0x17c [hp_accel]
 [<ffffffff81233e11>] acpi_device_probe+0x49/0x117
[...]
Code: 3a 75 06 80 4d ef 50 eb 04 80 4d ef 40 0f b6 55 ef be 21
00 00 00 48 89 df ff 53 18 44 8b 63 6c e8 3e fc ff ff 89 c1 44
89 e0 99 <f7> f9 89 c7 e8 93 82 ef e0 48 83 7b 30 00 74 2d 45
31 e4 80 7b=20
RIP  [<ffffffffa014b427>] lis3lv02d_poweron+0x4e/0x94 [lis3lv02d]
 RSP <ffff8801d6407cf8>

>From my POV, it looks like the hardware is not working as expected
and returns a bogus data rate. The driver doesn't check the result
and directly uses it as some sort of divisor in some places:

msleep(lis3->pwron_delay / lis3lv02d_get_odr());

Under this circumstances, this could very well cause the
"divide by zero" exception from above.

For now, I fixed it the easiest and most obvious way:
Check if the result is sane and if it isn't use a sane default
instead. I went for "100" in the latter case, simply because
/sys/devices/platform/lis3lv02d/rate returns it on a successful
boot.

Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
Signed-off-by: Éric Piel <eric.piel@tremplin-utc.net>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: Witold Pilat <witold.pilat@gmail.com>
Cc: Lyall Pearce <lyall.pearce@hp.com>
Cc: Malte Starostik <m-starostik@versanet.de>
Cc: Ilkka Koskinen <ilkka.koskinen@nokia.com>
Cc: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Cc: Christian Lamparter <chunkeey@googlemail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-31 17:30:51 -07:00
..
c2port Fix common misspellings 2011-03-31 11:26:23 -03:00
carma misc: Add CARMA DATA-FPGA Programmer support 2011-05-19 16:55:10 +10:00
cb710 mmc: cb710: fix possible pci_dev leak in cb710_pci_configure() 2011-08-13 14:50:23 -04:00
eeprom misc/eeprom: add eeprom access driver for digsy_mtc board 2011-07-25 20:57:16 -07:00
ibmasm Merge branch 'master' into for-next 2011-04-26 10:22:59 +02:00
iwmc3200top Fix common misspellings 2011-03-31 11:26:23 -03:00
lis3lv02d lis3lv02d: avoid divide by zero due to unchecked 2011-10-31 17:30:51 -07:00
sgi-gru sanitize <linux/prefetch.h> usage 2011-05-20 12:50:29 -07:00
sgi-xp sgi-xp: fix a use after free 2011-06-19 16:28:03 -07:00
ti-st drivers:misc: ti-st: fix unexpected UART close 2011-08-22 14:13:35 -07:00
ab8500-pwm.c drivers/misc/ab8500-pwm.c: fix modalias 2011-08-25 16:25:35 -07:00
ad525x_dpot-i2c.c drivers/misc/ad525x_dpot.c: new features 2010-10-26 16:52:14 -07:00
ad525x_dpot-spi.c drivers/misc/ad525x_dpot.c: new features 2010-10-26 16:52:14 -07:00
ad525x_dpot.c drivers/misc/ad525x_dpot.c: new features 2010-10-26 16:52:14 -07:00
ad525x_dpot.h ad525x_dpot: use correct rdac channel for ad5251/ad5252 2010-10-26 16:52:14 -07:00
apds990x.c drivers/misc/apds990x.c: apds990x_chip_on() should depend on CONFIG_PM || CONFIG_PM_RUNTIME 2011-06-15 20:04:02 -07:00
apds9802als.c drivers/misc/apds9802als.c: put the device into runtime suspend after resume()/probe() is handled 2011-03-22 17:44:10 -07:00
arm-charlcd.c tree-wide: fix comment/printk typos 2010-11-01 15:38:34 -04:00
atmel_pwm.c treewide: Convert uses of struct resource to resource_size(ptr) 2011-06-10 14:55:36 +02:00
atmel_tclib.c drivers/misc/atmel_tclib.c: fix a memory leak 2011-03-22 17:44:11 -07:00
atmel-ssc.c treewide: Convert uses of struct resource to resource_size(ptr) 2011-06-10 14:55:36 +02:00
bh1770glc.c drivers/misc/bh1770glc.c: error handling in bh1770_power_state_store() 2010-11-12 07:55:31 -08:00
bh1780gli.c treewide: cleanup continuations and remove logging message whitespace 2011-04-26 10:24:37 +02:00
bmp085.c Fix common misspellings 2011-03-31 11:26:23 -03:00
cs5535-mfgpt.c drivers/misc/cs5535-mfgpt.c: fix wrong if condition 2011-06-15 20:04:00 -07:00
ds1682.c sysfs: add struct file* to bin_attr callbacks 2010-05-21 09:37:31 -07:00
enclosure.c [SCSI] enclosure: fix error path - actually return ERR_PTR() on error 2010-07-27 12:03:48 -05:00
ep93xx_pwm.c drivers/misc/ep93xx_pwm.c: world-writable sysfs files 2011-03-22 17:44:11 -07:00
fsa9480.c drivers/misc/fsa9480.c: fix a leak of the IRQ during init failure 2011-08-25 16:25:35 -07:00
hmc6352.c drivers/misc/hmc6352.c: fix wrong return value checking for i2c_master_recv() 2011-03-22 17:44:10 -07:00
hpilo.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6 2010-10-22 19:36:42 -07:00
hpilo.h hpilo: fix pointer warning in ilo_ccb_setup 2010-08-09 20:45:05 -07:00
ics932s401.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
ioc4.c drivers/misc/ioc4.c: fix section mismatch / race condition 2011-06-27 18:00:13 -07:00
isl29003.c isl29003: fix resume functionality 2009-05-06 16:36:10 -07:00
isl29020.c drivers/misc/isl29020.c: remove incorrect kfree in isl29020_remove() 2010-11-25 06:50:47 +09:00
Kconfig pti: add missing CONFIG_PCI dependency 2011-08-22 14:12:23 -07:00
kgdbts.c kgdbts: only use new asm-generic/ptrace.h api when needed 2011-06-01 16:35:01 +09:00
lkdtm.c drivers/misc/lkdtm.c: fix race when crashpoint is hit multiple times before checking count 2011-06-27 18:00:13 -07:00
Makefile Merge branch 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6 2011-07-25 23:09:27 -07:00
pch_phub.c pch_phub: use kernel's '%pM' format option to print MAC 2011-08-22 17:54:59 -07:00
phantom.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
pti.c drivers/misc/pti.c: give 'comm' function scope in pti_control_frame_built_and_sent() 2011-09-14 18:09:38 -07:00
spear13xx_pcie_gadget.c drivers/misc/spear13xx_pcie_gadget.c: fix a memory leak in spear_pcie_gadget_probe error path 2011-06-15 20:04:00 -07:00
ti_dac7512.c drivers/misc: add driver for Texas Instruments DAC7512 2009-12-15 08:53:25 -08:00
tifm_7xx1.c dma-mapping: replace all DMA_32BIT_MASK macro with DMA_BIT_MASK(32) 2009-04-07 08:31:11 -07:00
tifm_core.c workqueue, freezer: unify spelling of 'freeze' + 'able' to 'freezable' 2011-02-16 17:48:59 +01:00
tsl2550.c tsl2550: Move from i2c/chips to misc 2010-03-13 20:56:54 +01:00
vmw_balloon.c Vmware balloon: switch to using sysem-wide freezable workqueue 2011-07-26 16:49:45 -07:00