diff options
author | royale@royale <royale@royale> | 2007-05-20 14:12:10 +0200 |
---|---|---|
committer | royale@royale <royale@royale> | 2007-05-20 14:12:10 +0200 |
commit | 2454fcc21cbbd3c59ae9205c2d99b7849a5c5bed (patch) | |
tree | 7b0409436cd64b2b8ab683a33428cef11ad1bc89 /linux | |
parent | 9e64c6766c66005d13e7522e9e14c43b6388db30 (diff) | |
download | mediapointer-dvb-s2-2454fcc21cbbd3c59ae9205c2d99b7849a5c5bed.tar.gz mediapointer-dvb-s2-2454fcc21cbbd3c59ae9205c2d99b7849a5c5bed.tar.bz2 |
zr364xx: fix return values
From: Akinobu Mita <akinobu.mita@gmail.com>
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>
Diffstat (limited to 'linux')
-rw-r--r-- | linux/drivers/media/video/zr364xx.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/linux/drivers/media/video/zr364xx.c b/linux/drivers/media/video/zr364xx.c index 88b1fec85..b72d153c5 100644 --- a/linux/drivers/media/video/zr364xx.c +++ b/linux/drivers/media/video/zr364xx.c @@ -797,6 +797,7 @@ static int zr364xx_probe(struct usb_interface *intf, { struct usb_device *udev = interface_to_usbdev(intf); struct zr364xx_camera *cam = NULL; + int err; DBG("probing..."); @@ -804,12 +805,11 @@ static int zr364xx_probe(struct usb_interface *intf, info("model %04x:%04x detected", udev->descriptor.idVendor, udev->descriptor.idProduct); - if ((cam = - kmalloc(sizeof(struct zr364xx_camera), GFP_KERNEL)) == NULL) { + cam = kzalloc(sizeof(struct zr364xx_camera), GFP_KERNEL); + if (cam == NULL) { info("cam: out of memory !"); - return -ENODEV; + return -ENOMEM; } - memset(cam, 0x00, sizeof(struct zr364xx_camera)); /* save the init method used by this camera */ cam->method = id->driver_info; @@ -817,7 +817,7 @@ static int zr364xx_probe(struct usb_interface *intf, if (cam->vdev == NULL) { info("cam->vdev: out of memory !"); kfree(cam); - return -ENODEV; + return -ENOMEM; } memcpy(cam->vdev, &zr364xx_template, sizeof(zr364xx_template)); video_set_drvdata(cam->vdev, cam); @@ -863,12 +863,13 @@ static int zr364xx_probe(struct usb_interface *intf, cam->brightness = 64; mutex_init(&cam->lock); - if (video_register_device(cam->vdev, VFL_TYPE_GRABBER, -1) == -1) { + err = video_register_device(cam->vdev, VFL_TYPE_GRABBER, -1); + if (err) { info("video_register_device failed"); video_device_release(cam->vdev); kfree(cam->buffer); kfree(cam); - return -ENODEV; + return err; } usb_set_intfdata(intf, cam); @@ -910,7 +911,7 @@ static struct usb_driver zr364xx_driver = { static int __init zr364xx_init(void) { int retval; - retval = usb_register(&zr364xx_driver) < 0; + retval = usb_register(&zr364xx_driver); if (retval) info("usb_register failed!"); else |