diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-11-18 14:23:19 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-11-20 20:19:20 +0100 |
commit | 625ff1679456d8adb9af0c980394ea3954e727a8 (patch) | |
tree | c1678e41cdd64ba37fc36d2c34bbd31565027f6b | |
parent | V4L/DVB (9639): Make dib0700 remote control support work with firmware v1.20 (diff) | |
download | linux-625ff1679456d8adb9af0c980394ea3954e727a8.tar.xz linux-625ff1679456d8adb9af0c980394ea3954e727a8.zip |
V4L/DVB (9645): em28xx: Avoid memory leaks if registration fails
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>
-rw-r--r-- | drivers/media/video/em28xx/em28xx-video.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index a1ab2ef45578..bca5955339b8 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c @@ -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); |