[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1324209529-15892-1-git-send-email-ozaki.ryota@gmail.com>
Date: Sun, 18 Dec 2011 20:58:49 +0900
From: Ryota Ozaki <ozaki.ryota@...il.com>
To: linux-kernel@...r.kernel.org, Greg Kroah-Hartman <gregkh@...e.de>
Cc: linux-mm@...ck.org, stable@...nel.org
Subject: [PATCH][RESEND] mm: Fix off-by-one bug in print_nodes_state
/sys/devices/system/node/{online,possible} involve 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 since v2.6.24.
Signed-off-by: Ryota Ozaki <ozaki.ryota@...il.com>
---
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 5693ece..ef7c1f9 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -587,11 +587,9 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
{
int n;
- n = nodelist_scnprintf(buf, PAGE_SIZE, node_states[state]);
- if (n > 0 && PAGE_SIZE > n + 1) {
- *(buf + n++) = '\n';
- *(buf + n++) = '\0';
- }
+ n = nodelist_scnprintf(buf, PAGE_SIZE-2, node_states[state]);
+ buf[n++] = '\n';
+ buf[n] = '\0';
return n;
}
--
1.7.5.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists