aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2006-07-25 08:31:42 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-07-29 16:22:34 -0400
commit53dd8def52100ed8be4dae0cf1c2dc1f7e0fcd2c (patch)
treeca1d6f085b8ca3dcfa07a9f00b24b4216b5a5ea9 /drivers/media
parentdf2732706c745c827762aaf51892f281fb937680 (diff)
V4L/DVB (4367): Videodev: Handle class_device related errors
Add proper error checking and roll-back for failure of class_device_create_file() in videodev.c. Print error messages and unroll partially created sysfs entries. Also, failure of class_device_register() in video_register_device() is handled correctly. It was failing to de-allocate the minor number. This must be done in video_register_device(), since the caller has no way of knowing if failure occurred before or after the class device was registered. Also added an error message if video_register_device() is called with an unknown type, which should never happen. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/videodev.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 5c5281981231..caa4f736468a 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -1538,6 +1538,8 @@ int video_register_device(struct video_device *vfd, int type, int nr)
1538 name_base = "radio"; 1538 name_base = "radio";
1539 break; 1539 break;
1540 default: 1540 default:
1541 printk(KERN_ERR "%s called with unknown type: %d\n",
1542 __FUNCTION__, type);
1541 return -1; 1543 return -1;
1542 } 1544 }
1543 1545
@@ -1592,6 +1594,15 @@ int video_register_device(struct video_device *vfd, int type, int nr)
1592 "http://lwn.net/Articles/36850/\n", vfd->name); 1594 "http://lwn.net/Articles/36850/\n", vfd->name);
1593#endif 1595#endif
1594 return 0; 1596 return 0;
1597
1598fail_classdev:
1599 class_device_unregister(&vfd->class_dev);
1600fail_minor:
1601 mutex_lock(&videodev_lock);
1602 video_device[vfd->minor] = NULL;
1603 vfd->minor = -1;
1604 mutex_unlock(&videodev_lock);
1605 return ret;
1595} 1606}
1596 1607
1597/** 1608/**