]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/char_dev.c
[PATCH] add check to /proc/devices read routines
[linux-2.6-omap-h63xx.git] / fs / char_dev.c
index c1e3537909fc1ae78f829220700810b78f371480..e82aac9cc2f5b9d39101e372cdab81dd971725a0 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;