From a51dd4ea79a5c23d0a701ec0cffb8fe7e190e2b8 Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Tue, 18 Jul 2006 16:17:31 -0300 Subject: videodev: check the return value of class_device_register From: Michael Krufky If an error occurs during class_device_register, print an error message, kfree(&vfd->class_dev), and return the error code to the caller of video_register_device. Signed-off-by: Michael Krufky --- linux/drivers/media/video/videodev.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'linux/drivers/media') diff --git a/linux/drivers/media/video/videodev.c b/linux/drivers/media/video/videodev.c index 5bc4e34dc..b13bbfe61 100644 --- a/linux/drivers/media/video/videodev.c +++ b/linux/drivers/media/video/videodev.c @@ -1532,6 +1532,7 @@ int video_register_device(struct video_device *vfd, int type, int nr) int i=0; int base; int end; + int ret; char *name_base; switch(type) @@ -1597,7 +1598,13 @@ int video_register_device(struct video_device *vfd, int type, int nr) vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor); #endif strlcpy(vfd->class_dev.class_id, vfd->devfs_name + 4, BUS_ID_SIZE); - class_device_register(&vfd->class_dev); + ret = class_device_register(&vfd->class_dev); + if (ret) { + printk(KERN_ERR "%s: class_device_register failed\n", + __FUNCTION__); + kfree(&vfd->class_dev); + return ret; + } video_device_create_file(vfd, &class_device_attr_name); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12) video_device_create_file(vfd, &class_device_attr_dev); -- cgit v1.2.3