diff options
author | Ryota Ozaki <ozaki.ryota@gmail.com> | 2012-05-29 18:06:20 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-29 19:22:19 -0400 |
commit | f62388187207bea83f1865d507bf892a1f9152c3 (patch) | |
tree | 734af4486b123cb15b6a5b49f37db24c74d82c5c /drivers/base/node.c | |
parent | 23b9da55c5b0feb484bd5e8615f4eb1ce4169453 (diff) |
mm: fix off-by-one bug in print_nodes_state()
/sys/devices/system/node/{online,possible} outputs a garbage byte
because print_nodes_state() returns content size + 1. To fix the bug,
the patch changes the use of cpuset_sprintf_cpulist to follow the use at
other places, which is clearer and safer.
This bug was introduced in v2.6.24 (commit bde631a51876: "mm: add node
states sysfs class attributeS").
Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/base/node.c')
-rw-r--r-- | drivers/base/node.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/base/node.c b/drivers/base/node.c index 90aa2a11a933..af1a177216f1 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c | |||
@@ -592,11 +592,9 @@ static ssize_t print_nodes_state(enum node_states state, char *buf) | |||
592 | { | 592 | { |
593 | int n; | 593 | int n; |
594 | 594 | ||
595 | n = nodelist_scnprintf(buf, PAGE_SIZE, node_states[state]); | 595 | n = nodelist_scnprintf(buf, PAGE_SIZE-2, node_states[state]); |
596 | if (n > 0 && PAGE_SIZE > n + 1) { | 596 | buf[n++] = '\n'; |
597 | *(buf + n++) = '\n'; | 597 | buf[n] = '\0'; |
598 | *(buf + n++) = '\0'; | ||
599 | } | ||
600 | return n; | 598 | return n; |
601 | } | 599 | } |
602 | 600 | ||