]> git.karo-electronics.de Git - linux-beck.git/commit
staging: comedi: ni_labpc: fix possible double-free of dma_buffer
authorIan Abbott <abbotti@mev.co.uk>
Fri, 28 Jun 2013 16:09:17 +0000 (17:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Jul 2013 21:27:50 +0000 (14:27 -0700)
commit725a70d8a68ef5368652c0c49631fefb361d62cf
tree71dfe83245b4881ae61c9c59edc027e9c73262f4
parentc383e2d6dacf0b6fdd40fbaf044e235cac54a20f
staging: comedi: ni_labpc: fix possible double-free of dma_buffer

If `labpc_attach()` allocates memory for `devpriv->dma_buffer` but fails
to request a DMA channel, it frees `devpriv->dma_buffer` but leaves the
pointer set.  Later, `labpc_detach()` frees `devpriv->dma_buffer` again,
which means it has been freed twice in this case.

Fix it by only setting `devpriv->dma_buffer` in `labpc_attach()` if the
DMA channel was requested successfully.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/ni_labpc.c