diff options
author | David Rientjes <rientjes@google.com> | 2010-03-10 14:50:21 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-19 07:12:22 -0700 |
commit | 12ee3c0a0ac42bed0939420468fd35f5cdceae4f (patch) | |
tree | c97f04d93fcca34d9ab7548f2b5070235202d52d /drivers/base/node.c | |
parent | f0eae0ed3b7d4182a6b4dd03540a738518ea3163 (diff) | |
download | blackbird-op-linux-12ee3c0a0ac42bed0939420468fd35f5cdceae4f.tar.gz blackbird-op-linux-12ee3c0a0ac42bed0939420468fd35f5cdceae4f.zip |
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/base/node.c')
-rw-r--r-- | drivers/base/node.c | 7 |
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, int len = 0; int i; - /* buf currently PAGE_SIZE, need ~4 chars per node */ - BUILD_BUG_ON(MAX_NUMNODES*4 > PAGE_SIZE/2); + /* + * buf is currently PAGE_SIZE in length and each node needs 4 chars + * at the most (distance + space or newline). + */ + BUILD_BUG_ON(MAX_NUMNODES * 4 > PAGE_SIZE); for_each_online_node(i) len += sprintf(buf + len, "%s%d", i ? " " : "", node_distance(nid, i)); |