Skip to content

Commit

Permalink
V4L/DVB (9645): em28xx: Avoid memory leaks if registration fails
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mauro Carvalho Chehab committed Nov 20, 2008
1 parent 99afb98 commit 625ff16
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions drivers/media/video/em28xx/em28xx-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 625ff16

Please sign in to comment.