V4L/DVB (4994): Vivi: fix use after free in list_for_each()
authorAkinobu Mita <akinobu.mita@gmail.com>
Wed, 20 Dec 2006 13:03:53 +0000 (10:03 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 27 Dec 2006 16:20:07 +0000 (14:20 -0200)
Freeing data including list_head in list_for_each() is not safe.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/vivi.c

index 474ddb779643a0495737bd718eb9225f4e5f6399..3cead24a36c123fa3d9386c250d2b3d47f65a2f2 100644 (file)
@@ -1363,7 +1363,9 @@ static void __exit vivi_exit(void)
        struct vivi_dev *h;
        struct list_head *list;
 
-       list_for_each(list,&vivi_devlist) {
+       while (!list_empty(&vivi_devlist)) {
+               list = vivi_devlist.next;
+               list_del(list);
                h = list_entry(list, struct vivi_dev, vivi_devlist);
                kfree (h);
        }