linux/drivers
Ian Abbott af93da3163 staging: comedi: protect buffer from being freed while mmapped
If a comedi device is automatically detached by `comedi_auto_unconfig()`
any data buffers associated with subdevices that support asynchronous
commands will be freed.  If the buffer is mmapped at the time, bad
things are likely to happen!  Prevent this by moving some of the buffer
details from `struct comedi_async` into a new, dynamically allocated,
and kref-counted `struct comedi_buf_map`.  This holds a list of pages, a
reference count, and enough information to free the pages.  The new
member `buf_map` of `struct comedi_async` points to a `struct
comedi_buf_map` when the buffer size is non-zero.

Provide a new helper function `comedi_buf_is_mapped()` to check whether
an a buffer is mmapped.  If it is mmapped, the buffer is not allowed to
be resized and the device is not allowed to be manually detached by the
`COMEDI_DEVCONFIG` ioctl.  Provide helper functions
`comedi_buf_map_get()` and `comedi_buf_map_put()` to manipulate the
reference count of the `struct comedi_buf_map`, which will be freed
along with its contents via the 'release' callback of the `kref_put()`
call.  The reference count is manipulated by the vma operations and the
mmap file operation.

Now, when the comedi device is automatically detached, the buffer will
be effectively freed by calling `comedi_buf_alloc()` with a new buffer
size of 0.  That calls local function `__comedi_buf_free()` which calls
`comedi_buf_map_put()` on the `buf_map` member to free it.  It won't
actually be freed until the final 'put'.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2013-11-11 16:16:45 -08:00
..
accessibility printk: move braille console support into separate braille.[ch] files 2013-07-31 14:41:03 -07:00
acpi ACPI / PM: Drop two functions that are not used any more 2013-10-17 15:44:48 +02:00
amba PM / Runtime: Rework the "runtime idle" helper routine 2013-06-03 21:49:52 +02:00
ata ATA / ACPI: remove power dependent device handling 2013-10-17 15:38:53 +02:00
atm atm: nicstar: fix regression made by previous patch 2013-09-15 22:18:55 -04:00
auxdisplay Drivers: misc: remove __dev* attributes. 2013-01-03 15:57:16 -08:00
base driver core: Release device_hotplug_lock when store_mem_state returns EINVAL 2013-10-16 18:42:41 -07:00
bcma bcma: make bcma_core_pci_{up,down}() callable from atomic context 2013-09-26 14:02:33 -04:00
block cciss: fix info leak in cciss_ioctl32_passthru() 2013-09-24 17:00:26 -07:00
bluetooth Bluetooth: btusb: Add support for Belkin F8065bf 2013-09-23 17:44:25 -03:00
bus bus: mvebu-mbus: Fix optional pcie-mem/io-aperture properties 2013-10-01 17:04:17 +00:00
cdrom drivers/cdrom/cdrom.c: use kzalloc() for failing hardware 2013-07-03 16:07:25 -07:00
char A small fix for Xen on x86_32 and a build fix for xen-tpmfront on arm64. 2013-10-15 16:22:11 -07:00
clk The common clk framework changes for 3.12 are dominated by clock driver 2013-09-09 15:49:04 -07:00
clocksource clocksource: em_sti: Set cpu_possible_mask to fix SMP broadcast 2013-09-26 02:31:04 +02:00
connector connector: replace obsolete NLMSG_* with type safe nlmsg_* 2013-03-28 14:27:44 -04:00
cpufreq cpufreq: s3c64xx: Rename index to driver_data 2013-10-16 23:53:38 +02:00
cpuidle ACPI and power management fixes for 3.12-rc1 2013-09-12 11:22:45 -07:00
crypto Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux 2013-09-07 12:53:35 +10:00
dca dca: convert to idr_alloc() 2013-02-27 19:10:15 -08:00
devfreq devfreq: convert devfreq_class to use dev_groups 2013-08-19 21:22:34 -07:00
dio m68k: don't export static inline functions 2009-12-06 11:18:28 +01:00
dma dma: edma.c: remove edma_desc leakage 2013-10-11 07:31:47 +05:30
edac Merge git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile 2013-09-06 11:14:33 -07:00
eisa PCI changes for the v3.10 merge window: 2013-04-29 09:30:25 -07:00
extcon Driver core patches for 3.12-rc1 2013-09-03 11:37:15 -07:00
firewire firewire: ohci: Fix deadlock at bus reset 2013-08-29 22:35:05 +02:00
firmware firmware/dmi_scan: drop OOM messages 2013-09-11 15:58:51 -07:00
fmc FMC: Staticize local symbols 2013-08-12 15:45:40 -07:00
gpio gpiolib: let gpiod_request() return -EPROBE_DEFER 2013-10-11 16:31:54 +02:00
gpu Revert "i915: Update VGA arbiter support for newer devices" 2013-10-11 15:19:22 +10:00
hid Merge 3.12-rc6 into staging-next. 2013-10-19 13:14:34 -07:00
hsi drivers: avoid format string in dev_set_name 2013-07-03 16:07:41 -07:00
hv Revert "Drivers: hv: vmbus: Fix a bug in channel rescind code" 2013-10-17 09:30:10 -07:00
hwmon hwmon: (applesmc) Always read until end of data 2013-10-09 09:48:55 -07:00
hwspinlock A single patch from Vincent extending OMAP's hwspinlock support to OMAP5. 2013-05-07 14:01:27 -07:00
i2c i2c: i2c-mux-pinctrl: use deferred probe when adapter not found 2013-10-10 10:22:35 +02:00
ide ide: sgiioc4: Staticize ioc4_ide_attach_one() 2013-09-05 15:21:30 -04:00
idle Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux 2013-05-11 15:23:17 -07:00
iio iio: light: vcnl4000: Remove redundant code 2013-10-24 14:48:14 +01:00
infiniband Last batch of IB changes for 3.12: many mlx5 hardware driver fixes plus 2013-10-14 17:43:33 -07:00
input First round of new drivers, functionality and cleanups for IIO in the 3.13 cycle 2013-09-22 11:30:12 -07:00
iommu x86, build, pci: Fix PCI_MSI build on !SMP 2013-10-04 10:43:34 -07:00
ipack ipack: split ipack_device_register() in several functions 2013-03-15 12:23:09 -07:00
irqchip ARM: SoC late changes for v3.12 2013-09-09 16:35:29 -07:00
isdn isdn: hfcpci_softirq: get func return to suppress compiler warning 2013-09-15 22:27:04 -04:00
leds Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds 2013-09-12 11:35:33 -07:00
lguest lguest: fix guest kernel stack overflow when TF bit set. 2013-09-06 08:09:27 +09:30
macintosh macintosh/ams: Replace strict_strtoul() with kstrtoul() 2013-08-14 14:57:43 +10:00
mailbox mailbox: remove unnecessary platform_set_drvdata() 2013-09-18 12:02:00 -07:00
md dm snapshot: fix data corruption 2013-10-16 03:17:47 +01:00
media Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
memory ARM: SoC platform changes for 3.12 2013-09-06 13:30:06 -07:00
memstick memstick: add support for legacy memorysticks 2013-09-11 15:59:35 -07:00
message drivers: avoid format strings in names passed to alloc_workqueue() 2013-07-03 16:07:41 -07:00
mfd Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
misc mei: cancel stall timers in mei_reset 2013-09-26 13:56:53 -07:00
mmc ARM: shmobile: update SDHI DT compatibility string to the <unit>-<soc> format 2013-09-21 09:55:32 -07:00
mtd mtd: m25p80: Fix 4 byte addressing mode for Micron devices. 2013-09-27 05:56:22 -05:00
net Last batch of IB changes for 3.12: many mlx5 hardware driver fixes plus 2013-10-14 17:43:33 -07:00
nfc NFC: pn544: i2c: Add firmware download implementation for pn544 2013-08-14 01:13:35 +02:00
ntb ntb: clean up unnecessary MSI/MSI-X capability find 2013-09-05 11:08:01 -07:00
nubus nubus: Kill nubus_proc_detach_device() 2013-05-04 14:47:26 -04:00
of Revert "drivers: of: add initialization code for dma reserved memory" 2013-10-15 09:26:07 +01:00
oprofile oprofile: get rid of pointless forward declarations of struct super_block 2013-09-03 22:52:48 -04:00
parisc PCI changes for the v3.12 merge window: 2013-09-03 16:24:35 -07:00
parport drivers: parport: Kconfig: exclude h8300 for PARPORT_PC 2013-08-30 12:08:04 -07:00
pci ACPI / hotplug / PCI: Drop WARN_ON() from acpiphp_enumerate_slots() 2013-10-12 01:49:48 +02:00
pcmcia PCI: Delay enabling bridges until they're needed 2013-07-25 12:35:03 -06:00
pinctrl pinctrl: palmas: do not abort pin configuration for BIAS_DEFAULT 2013-09-27 16:22:43 +02:00
platform Merge branch 'for_linus' of git://cavan.codon.org.uk/platform-drivers-x86 2013-09-15 17:42:59 -04:00
pnp pnp: change pnp bus pm_ops to invoke pnp driver dev_pm_ops if specified 2013-09-11 15:58:15 -07:00
power Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
pps Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
ps3 Drivers: misc: remove __dev* attributes. 2013-01-03 15:57:16 -08:00
ptp PTP: convert class code to use dev_groups 2013-07-26 18:05:17 -07:00
pwm ARM: SoC cleanups for 3.12 2013-09-06 13:21:16 -07:00
rapidio rapidio: fix use after free in rio_unregister_scan() 2013-07-31 14:41:02 -07:00
regulator Merge remote-tracking branch 'regulator/fix/wm8350' into regulator-linus 2013-09-30 12:04:33 +01:00
remoteproc remoteproc: don't use PTR_RET(). 2013-07-15 11:25:04 +09:30
reset reset: NULL deref on allocation failure 2013-04-12 10:26:24 +02:00
rpmsg A small pull request consisting of: 2013-05-07 14:02:00 -07:00
rtc HID RTC: Open sensor hub open close 2013-10-01 22:06:15 +01:00
s390 s390/sclp: properly detect line mode console 2013-09-30 13:04:39 +02:00
sbus bbc_i2c: fix section mismatch warning 2013-03-31 19:29:12 -04:00
scsi Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2013-09-19 13:57:28 -05:00
sfi drivers/sfi: sfi_acpi.c needs sysfs.h 2011-10-31 19:31:57 -04:00
sh Merge branch 'pm-assorted' 2013-06-28 13:01:40 +02:00
sn Drivers: misc: remove __dev* attributes. 2013-01-03 15:57:16 -08:00
spi Merge remote-tracking branch 'spi/fix/s3c64xx' into spi-linus 2013-10-07 14:51:59 +01:00
ssb ssb: drop BROKEN from SSB_SFLASH 2013-08-01 15:49:33 -04:00
staging staging: comedi: protect buffer from being freed while mmapped 2013-11-11 16:16:45 -08:00
target iscsi-target; Allow an extra tag_num / 2 number of percpu_ida tags 2013-10-03 14:22:45 -07:00
tc 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
thermal drivers: thermal: add check when unregistering cpu cooling 2013-09-03 09:10:34 -04:00
tty serial: vt8500: add missing braces 2013-10-16 13:22:16 -07:00
uio Driver core patches for 3.12-rc1 2013-09-03 11:37:15 -07:00
usb usb: misc: usb3503: Fix compile error due to incorrect regmap depedency 2013-10-16 13:52:16 -07:00
uwb uwb: Staticize local symbols 2013-08-19 17:08:16 -07:00
vfio VFIO: vfio_iommu_type1: fix bug caused by break in nested loop 2013-10-11 10:40:46 -06:00
vhost vhost/scsi: Use GFP_ATOMIC with percpu_ida_alloc for obtaining tag 2013-10-01 21:27:31 -07:00
video video: mxsfb: Add missing break 2013-09-26 15:33:23 +03:00
virt Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc 2012-12-18 09:58:09 -08:00
virtio virtio_pci: pm: Use CONFIG_PM_SLEEP instead of CONFIG_PM 2013-09-09 10:02:53 +09:30
vlynq drivers/vlynq: remove depends on CONFIG_EXPERIMENTAL 2013-01-17 12:11:27 -08:00
vme vme: vme_ca91cx42.c: fix to pass correct device identity to free_irq() 2013-08-27 21:49:26 -07:00
w1 w1 - call request_module with w1 master mutex unlocked 2013-10-07 00:12:14 -07:00
watchdog watchdog: sunxi: Fix section mismatch 2013-10-13 20:02:03 +02:00
xen Bug-fixes: 2013-09-25 15:50:53 -07:00
zorro zorro: switch to fixed_size_llseek() 2013-06-29 12:57:28 +04:00
Kconfig For the 3.11 merge we only have one new MFD driver for the Kontron PLD. 2013-07-10 11:10:27 -07:00
Makefile For the 3.11 merge we only have one new MFD driver for the Kontron PLD. 2013-07-10 11:10:27 -07:00