diff options
Diffstat (limited to 'drivers/media/radio/radio-mr800.c')
-rw-r--r-- | drivers/media/radio/radio-mr800.c | 27 |
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 | |||
744 | err_vdev: | ||
745 | v4l2_device_unregister(v4l2_dev); | ||
746 | err_v4l2: | ||
747 | kfree(radio->buffer); | ||
748 | err_nobuf: | ||
749 | kfree(radio); | ||
750 | err: | ||
751 | return retval; | ||
747 | } | 752 | } |
748 | 753 | ||
749 | static int __init amradio_init(void) | 754 | static int __init amradio_init(void) |