Commit 815d2d50da41f28aae58f5e9b3c61c3094422749

Authored by Andrew Morton
Committed by Greg Kroah-Hartman
1 parent c9698d6b1a

driver core: debug for bad dev_attr_show() return value.

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>

Showing 2 changed files with 12 additions and 1 deletions Side-by-side Diff

... ... @@ -19,6 +19,7 @@
19 19 #include <linux/kdev_t.h>
20 20 #include <linux/notifier.h>
21 21 #include <linux/genhd.h>
  22 +#include <linux/kallsyms.h>
22 23 #include <asm/semaphore.h>
23 24  
24 25 #include "base.h"
... ... @@ -68,6 +69,10 @@
68 69  
69 70 if (dev_attr->show)
70 71 ret = dev_attr->show(dev, dev_attr, buf);
  72 + if (ret >= (ssize_t)PAGE_SIZE) {
  73 + print_symbol("dev_attr_show: %s returned bad count\n",
  74 + (unsigned long)dev_attr->show);
  75 + }
71 76 return ret;
72 77 }
73 78  
... ... @@ -12,6 +12,7 @@
12 12  
13 13 #include <linux/module.h>
14 14 #include <linux/kobject.h>
  15 +#include <linux/kallsyms.h>
15 16 #include <linux/namei.h>
16 17 #include <linux/poll.h>
17 18 #include <linux/list.h>
... ... @@ -86,7 +87,12 @@
86 87 * The code works fine with PAGE_SIZE return but it's likely to
87 88 * indicate truncated result or overflow in normal use cases.
88 89 */
89   - BUG_ON(count >= (ssize_t)PAGE_SIZE);
  90 + if (count >= (ssize_t)PAGE_SIZE) {
  91 + print_symbol("fill_read_buffer: %s returned bad count\n",
  92 + (unsigned long)ops->show);
  93 + /* Try to struggle along */
  94 + count = PAGE_SIZE - 1;
  95 + }
90 96 if (count >= 0) {
91 97 buffer->needs_read_fill = 0;
92 98 buffer->count = count;