]> err.no Git - linux-2.6/commitdiff
V4L/DVB (4367): Videodev: Handle class_device related errors
authorTrent Piepho <xyzzy@speakeasy.org>
Tue, 25 Jul 2006 12:31:42 +0000 (09:31 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Sat, 29 Jul 2006 20:22:34 +0000 (17:22 -0300)
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>
drivers/media/video/videodev.c

index 5c5281981231d45da9624a8fb14b13c067f90126..caa4f736468a7ab4134910ab0f3b97537c7d8126 100644 (file)
@@ -1538,6 +1538,8 @@ int video_register_device(struct video_device *vfd, int type, int nr)
                        name_base = "radio";
                        break;
                default:
+                       printk(KERN_ERR "%s called with unknown type: %d\n",
+                              __FUNCTION__, type);
                        return -1;
        }
 
@@ -1592,6 +1594,15 @@ int video_register_device(struct video_device *vfd, int type, int nr)
                       "http://lwn.net/Articles/36850/\n", vfd->name);
 #endif
        return 0;
+
+fail_classdev:
+       class_device_unregister(&vfd->class_dev);
+fail_minor:
+       mutex_lock(&videodev_lock);
+       video_device[vfd->minor] = NULL;
+       vfd->minor = -1;
+       mutex_unlock(&videodev_lock);
+       return ret;
 }
 
 /**