aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2007-05-20 08:12:10 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-07-18 13:23:33 -0400
commit783aa8fa1fe666a039edb784d9458647da97d28a (patch)
tree0542723302160dbd4b666b40ad08cc256b119519
parent1b9d313c38291c6d60f1fbf6a2bc62c484fdaa21 (diff)
V4L/DVB (5678): Zr364xx: fix return values
This patch fixes several return value related problems in zr364xx. - return -ENOMEM instead of -ENODEV on out of memory - zr364xx checks video_register_device() error only when its return value is -1. But video_register_device() doesn't always return -1 on error. - If usb_register() returns error, module_init() wrongly returns 1: retval = usb_register(&zr364xx_driver) < 0; ... return retval; And it allows the module to be loaded. Because sys_init_module() doesn't see positive return value as error. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Antoine Jacquet <royale@zerezo.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--drivers/media/video/zr364xx.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c
index b5d3364c94c7..ba469ec108c7 100644
--- a/drivers/media/video/zr364xx.c
+++ b/drivers/media/video/zr364xx.c
@@ -792,6 +792,7 @@ static int zr364xx_probe(struct usb_interface *intf,
792{ 792{
793 struct usb_device *udev = interface_to_usbdev(intf); 793 struct usb_device *udev = interface_to_usbdev(intf);
794 struct zr364xx_camera *cam = NULL; 794 struct zr364xx_camera *cam = NULL;
795 int err;
795 796
796 DBG("probing..."); 797 DBG("probing...");
797 798
@@ -799,12 +800,11 @@ static int zr364xx_probe(struct usb_interface *intf,
799 info("model %04x:%04x detected", udev->descriptor.idVendor, 800 info("model %04x:%04x detected", udev->descriptor.idVendor,
800 udev->descriptor.idProduct); 801 udev->descriptor.idProduct);
801 802
802 if ((cam = 803 cam = kzalloc(sizeof(struct zr364xx_camera), GFP_KERNEL);
803 kmalloc(sizeof(struct zr364xx_camera), GFP_KERNEL)) == NULL) { 804 if (cam == NULL) {
804 info("cam: out of memory !"); 805 info("cam: out of memory !");
805 return -ENODEV; 806 return -ENOMEM;
806 } 807 }
807 memset(cam, 0x00, sizeof(struct zr364xx_camera));
808 /* save the init method used by this camera */ 808 /* save the init method used by this camera */
809 cam->method = id->driver_info; 809 cam->method = id->driver_info;
810 810
@@ -812,7 +812,7 @@ static int zr364xx_probe(struct usb_interface *intf,
812 if (cam->vdev == NULL) { 812 if (cam->vdev == NULL) {
813 info("cam->vdev: out of memory !"); 813 info("cam->vdev: out of memory !");
814 kfree(cam); 814 kfree(cam);
815 return -ENODEV; 815 return -ENOMEM;
816 } 816 }
817 memcpy(cam->vdev, &zr364xx_template, sizeof(zr364xx_template)); 817 memcpy(cam->vdev, &zr364xx_template, sizeof(zr364xx_template));
818 video_set_drvdata(cam->vdev, cam); 818 video_set_drvdata(cam->vdev, cam);
@@ -858,12 +858,13 @@ static int zr364xx_probe(struct usb_interface *intf,
858 cam->brightness = 64; 858 cam->brightness = 64;
859 mutex_init(&cam->lock); 859 mutex_init(&cam->lock);
860 860
861 if (video_register_device(cam->vdev, VFL_TYPE_GRABBER, -1) == -1) { 861 err = video_register_device(cam->vdev, VFL_TYPE_GRABBER, -1);
862 if (err) {
862 info("video_register_device failed"); 863 info("video_register_device failed");
863 video_device_release(cam->vdev); 864 video_device_release(cam->vdev);
864 kfree(cam->buffer); 865 kfree(cam->buffer);
865 kfree(cam); 866 kfree(cam);
866 return -ENODEV; 867 return err;
867 } 868 }
868 869
869 usb_set_intfdata(intf, cam); 870 usb_set_intfdata(intf, cam);
@@ -905,7 +906,7 @@ static struct usb_driver zr364xx_driver = {
905static int __init zr364xx_init(void) 906static int __init zr364xx_init(void)
906{ 907{
907 int retval; 908 int retval;
908 retval = usb_register(&zr364xx_driver) < 0; 909 retval = usb_register(&zr364xx_driver);
909 if (retval) 910 if (retval)
910 info("usb_register failed!"); 911 info("usb_register failed!");
911 else 912 else