Skip to contentSkip to conversation

use after free in drivers/media/video/em28xx/em28xx-video.c

PATCH New Eric Sesterhenn 1 participant 1 message Apr 10, 2006 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 use after free in drivers/media/video/em28xx/em28xx-video.c

hi,

in several we use dev->devno right after we kfree() dev. This fixes coverity bug id #1065

drivers/media/video/em28xx/em28xx-video.c renamed from drivers/media/video/em28xx/em28xx-video.c.orig +5 -5
@@ -1576,8 +1576,8 @@ static int em28xx_init_dev(struct em28xx
 	errCode = em28xx_config(dev);
 	if (errCode) {
 		em28xx_errdev("error configuring device\n");
-		kfree(dev);
 		em28xx_devused&=~(1<<dev->devno);
+		kfree(dev);
 		return -ENOMEM;
 	}
 
@@ -1603,8 +1603,8 @@ static int em28xx_init_dev(struct em28xx
 	dev->vdev = video_device_alloc();
 	if (NULL == dev->vdev) {
 		em28xx_errdev("cannot allocate video_device.\n");
-		kfree(dev);
 		em28xx_devused&=~(1<<dev->devno);
+		kfree(dev);
 		return -ENOMEM;
 	}
 
@@ -1612,8 +1612,8 @@ static int em28xx_init_dev(struct em28xx
 	if (NULL == dev->vbi_dev) {
 		em28xx_errdev("cannot allocate video_device.\n");
 		kfree(dev->vdev);
-		kfree(dev);
 		em28xx_devused&=~(1<<dev->devno);
+		kfree(dev);
 		return -ENOMEM;
 	}
 
@@ -1650,8 +1650,8 @@ static int em28xx_init_dev(struct em28xx
 		mutex_unlock(&dev->lock);
 		list_del(&dev->devlist);
 		video_device_release(dev->vdev);
-		kfree(dev);
 		em28xx_devused&=~(1<<dev->devno);
+		kfree(dev);
 		return -ENODEV;
 	}
 
@@ -1662,8 +1662,8 @@ static int em28xx_init_dev(struct em28xx
 		list_del(&dev->devlist);
 		video_device_release(dev->vbi_dev);
 		video_device_release(dev->vdev);
-		kfree(dev);
 		em28xx_devused&=~(1<<dev->devno);
+		kfree(dev);
 		return -ENODEV;
 	} else {
 		printk("registered VBI\n");