[PATCH] m68knommu: use THREAD_SIZE instead of hard coded size
[pandora-kernel.git] / fs / char_dev.c
index c1e3537..3b1b1ee 100644 (file)
@@ -56,10 +56,21 @@ int get_chrdev_list(char *page)
 
        down(&chrdevs_lock);
        for (i = 0; i < ARRAY_SIZE(chrdevs) ; i++) {
-               for (cd = chrdevs[i]; cd; cd = cd->next)
+               for (cd = chrdevs[i]; cd; cd = cd->next) {
+                       /*
+                        * if the current name, plus the 5 extra characters
+                        * in the device line for this entry
+                        * would run us off the page, we're done
+                        */
+                       if ((len+strlen(cd->name) + 5) >= PAGE_SIZE)
+                               goto page_full;
+
+
                        len += sprintf(page+len, "%3d %s\n",
                                       cd->major, cd->name);
+               }
        }
+page_full:
        up(&chrdevs_lock);
 
        return len;
@@ -139,7 +150,7 @@ __unregister_chrdev_region(unsigned major, unsigned baseminor, int minorct)
        struct char_device_struct *cd = NULL, **cp;
        int i = major_to_index(major);
 
-       up(&chrdevs_lock);
+       down(&chrdevs_lock);
        for (cp = &chrdevs[i]; *cp; cp = &(*cp)->next)
                if ((*cp)->major == major &&
                    (*cp)->baseminor == baseminor &&
@@ -266,8 +277,9 @@ static struct kobject *cdev_get(struct cdev *p)
 void cdev_put(struct cdev *p)
 {
        if (p) {
+               struct module *owner = p->owner;
                kobject_put(&p->kobj);
-               module_put(p->owner);
+               module_put(owner);
        }
 }