linux/drivers
Ian Abbott 92d354cbe9 staging: comedi: fix extreme case of comedi_nsamples_left()
`comedi_nsamples_left(s, nsamples)` returns the number of samples
remaining to complete an asynchronous command or the passed in
`nsamples`, whichever is lower.  However, it goes wrong in the extreme
case of setting the `nsamples` parameter to `UINT_MAX` when the number
of conversions per "scan" (`s->async->cmd.scan_end_arg`) is 1.  It uses
`comedi_nscans_remaining(s, nscans)` to determine the number of scans
remaining, or the parameter `nscans`, whichever is lower.  To determine
the parameter `nscans`, it divides `nsamples` by the number of
conversions per scan and adds 1.  The addition of 1 is to avoid setting
the parameter `nscans` to 0, as `comedi_nscans_remaining(s, nscans)`
treats that value specially.  However in the extreme case where
`nsamples` is `UINT_MAX` and the number of samples per scan is 1, the
addition of 1 to `nscans` overflows, producing the unwanted 0.

Fix it by refactoring new a function `__comedi_nscans_remaining(s,
nscans)` out of `comedi_nscans_remaining(s, nscans)`.  The new function
does everything except the special handling when `nscans` is 0.  Change
`comedi_nsamples_remaining()` to call the new function without adding 1
to `nscans` to avoid the overflow.

This overflow bug doesn't affect any of the current COMEDI drivers.  I
stumbled across it while changing to one of the drivers.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-27 14:31:25 +09:00
..
accessibility
acpi ACPICA: Tables: Fix FADT dependency regression 2015-10-14 22:48:13 +02:00
amba
android
ata
atm
auxdisplay
base mm: cma: fix incorrect type conversion for size during dma allocation 2015-10-23 17:55:10 +09:00
bcma
block Merge branch 'for-linus' of git://git.kernel.dk/linux-block 2015-10-24 07:20:57 +09:00
bluetooth
bus bus: arm-ccn: Fix irq affinity setting on CPU migration 2015-10-15 17:10:15 +02:00
cdrom
char
clk Partially revert "clk: mvebu: Convert to clk_hw based provider APIs" 2015-10-14 11:28:17 -07:00
clocksource clocksource/drivers/keystone: Fix bad NO_IRQ usage 2015-09-29 14:33:51 +02:00
connector
cpufreq cpufreq: intel_pstate: Fix divide by zero on Knights Landing (KNL) 2015-10-15 22:46:33 +02:00
cpuidle
crypto
dca
devfreq PM / devfreq: fix double kfree 2015-10-02 11:05:58 +09:00
dio
dma dmaengine fixes for 4.3-rc4 2015-10-02 14:46:15 -04:00
dma-buf
edac
eisa
extcon
firewire
firmware arm64/efi: Fix boot crash by not padding between EFI_MEMORY_RUNTIME regions 2015-10-01 12:51:28 +02:00
fmc
gpio
gpu Merge branch 'drm-fixes-4.3' of git://people.freedesktop.org/~agd5f/linux into drm-fixes 2015-10-22 10:24:55 +10:00
hid
hsi
hv
hwmon
hwspinlock
hwtracing/coresight
i2c i2c: designware: Do not use parameters from ACPI on Dell Inspiron 7348 2015-10-18 14:11:08 +02:00
ide
idle
iio Merge 4.3-rc7 into staging-next 2015-10-27 09:13:38 +09:00
infiniband Changes for 4.3-rc6 2015-10-24 07:28:05 +09:00
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2015-10-16 17:39:27 -07:00
iommu Merge tag 'for-linus-20151021' of git://git.infradead.org/intel-iommu 2015-10-22 06:32:48 +09:00
ipack
irqchip Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-10-04 11:40:09 +01:00
isdn
leds
lguest
macintosh
mailbox
mcb mcb: Fix error handling in mcb_pci_probe() 2015-10-05 05:10:01 +01:00
md dm cache: the CLEAN_SHUTDOWN flag was not being set 2015-10-23 14:02:56 -04:00
media [media] m88ds3103: use own reg update_bits() implementation 2015-10-22 15:48:28 -02:00
memory memory: omap-gpmc: dump "before" state before first modification 2015-10-12 16:23:34 -07:00
memstick
message
mfd mfd: max77843: Fix max77843_chg_init() return on error 2015-10-01 16:31:42 +01:00
misc powerpc fixes for 4.3 #3 2015-10-16 12:07:43 -07:00
mmc mmc: core: Fix init_card in 52Mhz 2015-10-21 10:18:11 +02:00
mtd A few MTD fixes: 2015-10-07 09:35:15 +01:00
net net: bcmgenet: Fix early link interrupt enabling 2015-10-18 23:07:12 -07:00
nfc
ntb
nubus
nvdimm
nvmem nvmem: sunxi: Check for memory allocation failure 2015-10-04 12:09:43 +01:00
of
oprofile
parisc
parport
pci genirq/msi: Do not use pci_msi_[un]mask_irq as default methods 2015-10-16 12:40:43 +02:00
pcmcia
perf drivers/perf: arm_pmu: avoid CPU device_node reference leak 2015-10-15 17:11:23 +02:00
phy
pinctrl pinctrl: uniphier: fix input enable settings for PH1-sLD8 2015-10-02 04:06:26 -07:00
platform
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator Merge remote-tracking branch 'regulator/fix/axp20x' into regulator-linus 2015-10-06 12:00:42 +01:00
remoteproc
reset
rpmsg
rtc
s390
sbus
scsi SCSI fixes on 20151010 2015-10-11 10:02:30 -07:00
sfi
sh
sn
soc
spi Merge remote-tracking branches 'spi/fix/davinci' and 'spi/fix/sh-msiof' into spi-linus 2015-10-07 11:43:39 +01:00
spmi
ssb
staging staging: comedi: fix extreme case of comedi_nsamples_left() 2015-10-27 14:31:25 +09:00
target
tc
thermal Samsung 2nd fixes for v4.3 2015-10-21 17:02:13 +02:00
thunderbolt
tty Revert "serial: 8250_dma: don't bother DMA with small transfers" 2015-10-17 21:24:46 -07:00
uio
usb xhci: Add spurious wakeup quirk for LynxPoint-LP controllers 2015-10-17 00:04:18 -07:00
uwb
vfio
vhost
video fbcon: initialize blink interval before calling fb_set_par 2015-10-17 22:00:39 -07:00
virt
virtio
vlynq
vme vme: tsi148: silence uninitialized variable warning 2015-10-05 10:59:34 +01:00
w1
watchdog
xen
zorro
Kconfig
Makefile