aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2010-03-10 17:50:21 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-19 10:12:22 -0400
commit12ee3c0a0ac42bed0939420468fd35f5cdceae4f (patch)
treec97f04d93fcca34d9ab7548f2b5070235202d52d /drivers
parentf0eae0ed3b7d4182a6b4dd03540a738518ea3163 (diff)
driver core: numa: fix BUILD_BUG_ON for node_read_distance
node_read_distance() has a BUILD_BUG_ON() to prevent buffer overruns when the number of nodes printed will exceed the buffer length. Each node only needs four chars: three for distance (maximum distance is 255) and one for a seperating space or a trailing newline. Signed-off-by: David Rientjes <rientjes@google.com> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/node.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/base/node.c b/drivers/base/node.c
index ad43185ec15a..93b3ac65c2d4 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -165,8 +165,11 @@ static ssize_t node_read_distance(struct sys_device * dev,
165 int len = 0; 165 int len = 0;
166 int i; 166 int i;
167 167
168 /* buf currently PAGE_SIZE, need ~4 chars per node */ 168 /*
169 BUILD_BUG_ON(MAX_NUMNODES*4 > PAGE_SIZE/2); 169 * buf is currently PAGE_SIZE in length and each node needs 4 chars
170 * at the most (distance + space or newline).
171 */
172 BUILD_BUG_ON(MAX_NUMNODES * 4 > PAGE_SIZE);
170 173
171 for_each_online_node(i) 174 for_each_online_node(i)
172 len += sprintf(buf + len, "%s%d", i ? " " : "", node_distance(nid, i)); 175 len += sprintf(buf + len, "%s%d", i ? " " : "", node_distance(nid, i));