diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-11-18 08:23:19 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-11-20 14:19:20 -0500 |
commit | 625ff1679456d8adb9af0c980394ea3954e727a8 (patch) | |
tree | c1678e41cdd64ba37fc36d2c34bbd31565027f6b /drivers/media | |
parent | 99afb989b05b9fb1c7b3831ce4b7a000b214acdb (diff) |
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>
Diffstat (limited to 'drivers/media')
-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, | |||
1953 | errCode = em28xx_config(dev); | 1953 | errCode = em28xx_config(dev); |
1954 | if (errCode) { | 1954 | if (errCode) { |
1955 | em28xx_errdev("error configuring device\n"); | 1955 | em28xx_errdev("error configuring device\n"); |
1956 | em28xx_devused &= ~(1<<dev->devno); | ||
1957 | kfree(dev); | ||
1958 | return -ENOMEM; | 1956 | return -ENOMEM; |
1959 | } | 1957 | } |
1960 | 1958 | ||
@@ -2088,7 +2086,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
2088 | fail_unreg: | 2086 | fail_unreg: |
2089 | em28xx_release_resources(dev); | 2087 | em28xx_release_resources(dev); |
2090 | mutex_unlock(&dev->lock); | 2088 | mutex_unlock(&dev->lock); |
2091 | kfree(dev); | ||
2092 | return retval; | 2089 | return retval; |
2093 | } | 2090 | } |
2094 | 2091 | ||
@@ -2231,8 +2228,12 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2231 | 2228 | ||
2232 | /* allocate device struct */ | 2229 | /* allocate device struct */ |
2233 | retval = em28xx_init_dev(&dev, udev, nr); | 2230 | retval = em28xx_init_dev(&dev, udev, nr); |
2234 | if (retval) | 2231 | if (retval) { |
2232 | em28xx_devused &= ~(1<<dev->devno); | ||
2233 | kfree(dev); | ||
2234 | |||
2235 | return retval; | 2235 | return retval; |
2236 | } | ||
2236 | 2237 | ||
2237 | em28xx_info("Found %s\n", em28xx_boards[dev->model].name); | 2238 | em28xx_info("Found %s\n", em28xx_boards[dev->model].name); |
2238 | 2239 | ||