aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio
diff options
context:
space:
mode:
authorDavid Ellingsworth <david@identd.dyndns.org>2009-09-22 20:43:19 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-12-05 15:40:08 -0500
commit1b8bbb3c0a719f3baac22ea4a7eb1d636383ba3b (patch)
tree36473bf1950c3fd05efc338d4bc12363cd1aed72 /drivers/media/radio
parent7a7d92e061ed13052d306cadad6972d52acea931 (diff)
V4L/DVB (13062): radio-mr800: simplify error paths in usb probe callback
Simplify error paths in usb probe callback. Signed-off-by: David Ellingsworth <david@identd.dyndns.org> Acked-by: Alexey Klimov <klimov.linux@gmail.com> Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/radio')
-rw-r--r--drivers/media/radio/radio-mr800.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c
index dd36ba0baab3..0c5d734b00fa 100644
--- a/drivers/media/radio/radio-mr800.c
+++ b/drivers/media/radio/radio-mr800.c
@@ -689,30 +689,29 @@ static int usb_amradio_probe(struct usb_interface *intf,
689{ 689{
690 struct amradio_device *radio; 690 struct amradio_device *radio;
691 struct v4l2_device *v4l2_dev; 691 struct v4l2_device *v4l2_dev;
692 int retval; 692 int retval = 0;
693 693
694 radio = kzalloc(sizeof(struct amradio_device), GFP_KERNEL); 694 radio = kzalloc(sizeof(struct amradio_device), GFP_KERNEL);
695 695
696 if (!radio) { 696 if (!radio) {
697 dev_err(&intf->dev, "kmalloc for amradio_device failed\n"); 697 dev_err(&intf->dev, "kmalloc for amradio_device failed\n");
698 return -ENOMEM; 698 retval = -ENOMEM;
699 goto err;
699 } 700 }
700 701
701 radio->buffer = kmalloc(BUFFER_LENGTH, GFP_KERNEL); 702 radio->buffer = kmalloc(BUFFER_LENGTH, GFP_KERNEL);
702 703
703 if (!radio->buffer) { 704 if (!radio->buffer) {
704 dev_err(&intf->dev, "kmalloc for radio->buffer failed\n"); 705 dev_err(&intf->dev, "kmalloc for radio->buffer failed\n");
705 kfree(radio); 706 retval = -ENOMEM;
706 return -ENOMEM; 707 goto err_nobuf;
707 } 708 }
708 709
709 v4l2_dev = &radio->v4l2_dev; 710 v4l2_dev = &radio->v4l2_dev;
710 retval = v4l2_device_register(&intf->dev, v4l2_dev); 711 retval = v4l2_device_register(&intf->dev, v4l2_dev);
711 if (retval < 0) { 712 if (retval < 0) {
712 dev_err(&intf->dev, "couldn't register v4l2_device\n"); 713 dev_err(&intf->dev, "couldn't register v4l2_device\n");
713 kfree(radio->buffer); 714 goto err_v4l2;
714 kfree(radio);
715 return retval;
716 } 715 }
717 716
718 strlcpy(radio->videodev.name, v4l2_dev->name, 717 strlcpy(radio->videodev.name, v4l2_dev->name,
@@ -736,14 +735,20 @@ static int usb_amradio_probe(struct usb_interface *intf,
736 radio_nr); 735 radio_nr);
737 if (retval < 0) { 736 if (retval < 0) {
738 dev_err(&intf->dev, "could not register video device\n"); 737 dev_err(&intf->dev, "could not register video device\n");
739 v4l2_device_unregister(v4l2_dev); 738 goto err_vdev;
740 kfree(radio->buffer);
741 kfree(radio);
742 return -EIO;
743 } 739 }
744 740
745 usb_set_intfdata(intf, radio); 741 usb_set_intfdata(intf, radio);
746 return 0; 742 return 0;
743
744err_vdev:
745 v4l2_device_unregister(v4l2_dev);
746err_v4l2:
747 kfree(radio->buffer);
748err_nobuf:
749 kfree(radio);
750err:
751 return retval;
747} 752}
748 753
749static int __init amradio_init(void) 754static int __init amradio_init(void)