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>

authored by David Rientjes and committed by Greg Kroah-Hartman 12ee3c0a f0eae0ed

+5 -2
+5 -2
drivers/base/node.c
··· 165 165 int len = 0; 166 166 int i; 167 167 168 - /* buf currently PAGE_SIZE, need ~4 chars per node */ 169 - BUILD_BUG_ON(MAX_NUMNODES*4 > PAGE_SIZE/2); 168 + /* 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 174 for_each_online_node(i) 172 175 len += sprintf(buf + len, "%s%d", i ? " " : "", node_distance(nid, i));