]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (9645): em28xx: Avoid memory leaks if registration fails
authorMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 18 Nov 2008 13:23:19 +0000 (10:23 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 20 Nov 2008 19:19:20 +0000 (17:19 -0200)
em28xx_init_dev() has some error conditions that are not properly
de-allocating dev var, nor freeing the device number for a future usage.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/em28xx/em28xx-video.c

index a1ab2ef45578d491ea9951ef1ddfe933b85294fb..bca5955339b8cee1bf1ee4acaa67ce0b04bf1985 100644 (file)
@@ -1953,8 +1953,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
        errCode = em28xx_config(dev);
        if (errCode) {
                em28xx_errdev("error configuring device\n");
-               em28xx_devused &= ~(1<<dev->devno);
-               kfree(dev);
                return -ENOMEM;
        }
 
@@ -2088,7 +2086,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
 fail_unreg:
        em28xx_release_resources(dev);
        mutex_unlock(&dev->lock);
-       kfree(dev);
        return retval;
 }
 
@@ -2231,8 +2228,12 @@ static int em28xx_usb_probe(struct usb_interface *interface,
 
        /* allocate device struct */
        retval = em28xx_init_dev(&dev, udev, nr);
-       if (retval)
+       if (retval) {
+               em28xx_devused &= ~(1<<dev->devno);
+               kfree(dev);
+
                return retval;
+       }
 
        em28xx_info("Found %s\n", em28xx_boards[dev->model].name);