driver core: debug for bad dev_attr_show() return value.
authorAndrew Morton <akpm@linux-foundation.org>
Tue, 4 Mar 2008 23:09:07 +0000 (15:09 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 25 Mar 2008 05:33:49 +0000 (22:33 -0700)
Try to find the culprit who caused
http://bugzilla.kernel.org/show_bug.cgi?id=10150

Cc: <balajirrao@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/core.c
fs/sysfs/file.c

index 7de543d1d0b4337328f95c502915d99b3a4fa871..24198ad0197654943ae95250b22386358cb22e71 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/kdev_t.h>
 #include <linux/notifier.h>
 #include <linux/genhd.h>
+#include <linux/kallsyms.h>
 #include <asm/semaphore.h>
 
 #include "base.h"
@@ -68,6 +69,10 @@ static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr,
 
        if (dev_attr->show)
                ret = dev_attr->show(dev, dev_attr, buf);
+       if (ret >= (ssize_t)PAGE_SIZE) {
+               print_symbol("dev_attr_show: %s returned bad count\n",
+                               (unsigned long)dev_attr->show);
+       }
        return ret;
 }
 
index a271c87c4472d530bee00c35da17a06606dfc97c..baa663e69388aeb623aeb667f86ff12540b741e8 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/module.h>
 #include <linux/kobject.h>
+#include <linux/kallsyms.h>
 #include <linux/namei.h>
 #include <linux/poll.h>
 #include <linux/list.h>
@@ -86,7 +87,12 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
         * The code works fine with PAGE_SIZE return but it's likely to
         * indicate truncated result or overflow in normal use cases.
         */
-       BUG_ON(count >= (ssize_t)PAGE_SIZE);
+       if (count >= (ssize_t)PAGE_SIZE) {
+               print_symbol("fill_read_buffer: %s returned bad count\n",
+                       (unsigned long)ops->show);
+               /* Try to struggle along */
+               count = PAGE_SIZE - 1;
+       }
        if (count >= 0) {
                buffer->needs_read_fill = 0;
                buffer->count = count;