linux/drivers/staging/comedi
Ian Abbott c8cad4c89e staging: comedi: fix memory leak for saved channel list
When `do_cmd_ioctl()` allocates memory for the kernel copy of a channel
list, it frees any previously allocated channel list in
`async->cmd.chanlist` and replaces it with the new one.  However, if the
device is ever removed (or "detached") the cleanup code in
`cleanup_device()` in "drivers.c" does not free this memory so it is
lost.

A sensible place to free the kernel copy of the channel list is in
`do_become_nonbusy()` as at that point the comedi asynchronous command
associated with the channel list is no longer valid.  Free the channel
list in `do_become_nonbusy()` instead of `do_cmd_ioctl()` and clear the
pointer to prevent it being freed more than once.

Note that `cleanup_device()` could be called at an inappropriate time
while the comedi device is open, but that's a separate bug not related
to this this patch.

Cc: stable@vger.kernel.org
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-09-21 09:29:53 -07:00
..
drivers staging: comedi: ni_labpc: pass ai scan mode through various functions 2012-09-21 09:29:53 -07:00
kcomedilib staging: comedi: kcomedilib: fix a __user space access issue 2012-09-21 09:26:20 -07:00
comedi_compat32.c staging: comedi: shrink comedi_compat32.h 2012-06-20 12:57:43 -07:00
comedi_compat32.h staging: comedi: shrink comedi_compat32.h 2012-06-20 12:57:43 -07:00
comedi_fops.c staging: comedi: fix memory leak for saved channel list 2012-09-21 09:29:53 -07:00
comedi_internal.h staging: comedi: remove comedi_fops.h 2012-06-20 12:56:55 -07:00
comedi.h staging: comedi: comedi.h: remove __user tag from chanlist 2012-09-19 09:36:44 +01:00
comedidev.h staging: comedi: replace printk calls in comedi core 2012-08-16 11:35:45 -07:00
comedilib.h Staging: comedi: kcomedilib: make it typesafe 2010-05-11 11:36:02 -07:00
drivers.c staging: comedi: sparse warning in insn_rw_emulate_bits() 2012-09-19 11:26:12 +01:00
Kconfig staging: comedi: 8255_pci: move ni_pcidio 8255 board support 2012-09-13 20:13:03 -07:00
Makefile Staging: comedi: Makefile: replace the use of <module>-objs with <module>-y 2010-10-08 07:23:52 -07:00
proc.c staging: comedi: remove comedi_fops.h 2012-06-20 12:56:55 -07:00
range.c staging: comedi: range: remove subdevice pointer math 2012-09-05 20:06:32 -07:00
TODO Staging: comedi: Remove typedefs 2010-06-17 13:49:07 -07:00