Staging: most: fix dereferencing freed memory
authorChristian Gromm <christian.gromm@microchip.com>
Tue, 28 Jul 2015 15:16:10 +0000 (17:16 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jul 2015 20:43:15 +0000 (13:43 -0700)
This patch fixes the dereferencing of freed memory.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/most/aim-cdev/cdev.c

index d5fb4a0e081833f40cd2e1bc5e63f769f6efae03..cfc32dff651277fe01e9a615e8ade33de8718614 100644 (file)
@@ -124,9 +124,9 @@ static int aim_close(struct inode *inode, struct file *filp)
                cdev_del(&channel->cdev);
                kfifo_free(&channel->fifo);
                list_del(&channel->list);
-               kfree(channel);
                ida_simple_remove(&minor_id, MINOR(channel->devno));
                wake_up_interruptible(&channel->wq);
+               kfree(channel);
                return 0;
        }
        mutex_unlock(&channel->io_mutex);