Commit 1b8bbb3c authored by David Ellingsworth's avatar David Ellingsworth Committed by Mauro Carvalho Chehab

V4L/DVB (13062): radio-mr800: simplify error paths in usb probe callback

Simplify error paths in usb probe callback.
Signed-off-by: default avatarDavid Ellingsworth <david@identd.dyndns.org>
Acked-by: default avatarAlexey Klimov <klimov.linux@gmail.com>
Signed-off-by: default avatarDouglas Schilling Landgraf <dougsland@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 7a7d92e0
...@@ -689,30 +689,29 @@ static int usb_amradio_probe(struct usb_interface *intf, ...@@ -689,30 +689,29 @@ static int usb_amradio_probe(struct usb_interface *intf,
{ {
struct amradio_device *radio; struct amradio_device *radio;
struct v4l2_device *v4l2_dev; struct v4l2_device *v4l2_dev;
int retval; int retval = 0;
radio = kzalloc(sizeof(struct amradio_device), GFP_KERNEL); radio = kzalloc(sizeof(struct amradio_device), GFP_KERNEL);
if (!radio) { if (!radio) {
dev_err(&intf->dev, "kmalloc for amradio_device failed\n"); dev_err(&intf->dev, "kmalloc for amradio_device failed\n");
return -ENOMEM; retval = -ENOMEM;
goto err;
} }
radio->buffer = kmalloc(BUFFER_LENGTH, GFP_KERNEL); radio->buffer = kmalloc(BUFFER_LENGTH, GFP_KERNEL);
if (!radio->buffer) { if (!radio->buffer) {
dev_err(&intf->dev, "kmalloc for radio->buffer failed\n"); dev_err(&intf->dev, "kmalloc for radio->buffer failed\n");
kfree(radio); retval = -ENOMEM;
return -ENOMEM; goto err_nobuf;
} }
v4l2_dev = &radio->v4l2_dev; v4l2_dev = &radio->v4l2_dev;
retval = v4l2_device_register(&intf->dev, v4l2_dev); retval = v4l2_device_register(&intf->dev, v4l2_dev);
if (retval < 0) { if (retval < 0) {
dev_err(&intf->dev, "couldn't register v4l2_device\n"); dev_err(&intf->dev, "couldn't register v4l2_device\n");
kfree(radio->buffer); goto err_v4l2;
kfree(radio);
return retval;
} }
strlcpy(radio->videodev.name, v4l2_dev->name, strlcpy(radio->videodev.name, v4l2_dev->name,
...@@ -736,14 +735,20 @@ static int usb_amradio_probe(struct usb_interface *intf, ...@@ -736,14 +735,20 @@ static int usb_amradio_probe(struct usb_interface *intf,
radio_nr); radio_nr);
if (retval < 0) { if (retval < 0) {
dev_err(&intf->dev, "could not register video device\n"); dev_err(&intf->dev, "could not register video device\n");
v4l2_device_unregister(v4l2_dev); goto err_vdev;
kfree(radio->buffer);
kfree(radio);
return -EIO;
} }
usb_set_intfdata(intf, radio); usb_set_intfdata(intf, radio);
return 0; return 0;
err_vdev:
v4l2_device_unregister(v4l2_dev);
err_v4l2:
kfree(radio->buffer);
err_nobuf:
kfree(radio);
err:
return retval;
} }
static int __init amradio_init(void) static int __init amradio_init(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment