From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel J Blueman Subject: [PATCH] Fix a SEGV due to uninitialised mask Date: Tue, 17 Feb 2015 12:06:51 +0800 Message-ID: <1424146011-28317-1-git-send-email-daniel@numascale.com> Return-path: DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=numascale.com; s=default; h=Message-Id:Date:Subject:Cc:To:From; bh=wrVg3tL0qO84VD27v9L3lc1Zspyp2Tv3m0djJwkxj54=; b=avWgonMEJ+a+cj3xus5hXwOBpUKb4L8AALw0RlXZ1bqYp5LaRlbsEe0tlMTqdAyQlDFqbSEAk3Nr10Ml7VoiRHyECKQnOeTB+6LEVDLWHm6x5s2KhzYP2ujOlbI8hPk62QFsI446GYfEe3kXjNAM2UO/Yn3kDSS/qRgyNFOc40E=; Sender: linux-numa-owner@vger.kernel.org List-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-numa@vger.kernel.org Cc: Daniel J Blueman , Steffen Persvold As node_cpu_mask_v2 is not defined as local to the compilation unit with 'static', it is not guaranteed to be initialised to zero (ie in the .bss). This was leading to some SEGVs we've seen. Also mark another internal function local to the compilation unit. Signed-off-by: Daniel J Blueman --- libnuma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libnuma.c b/libnuma.c index 8d7bf13..3717d5b 100644 --- a/libnuma.c +++ b/libnuma.c @@ -58,7 +58,7 @@ struct bitmask *numa_possible_cpus_ptr = NULL; struct bitmask *numa_nodes_ptr = NULL; static struct bitmask *numa_memnode_ptr = NULL; static unsigned long *node_cpu_mask_v1[NUMA_NUM_NODES]; -struct bitmask **node_cpu_mask_v2; +static struct bitmask **node_cpu_mask_v2; WEAK void numa_error(char *where); @@ -1234,7 +1234,7 @@ numa_parse_bitmap_v2(char *line, struct bitmask *mask) __asm__(".symver numa_parse_bitmap_v2,numa_parse_bitmap@@libnuma_1.2"); void -init_node_cpu_mask_v2(void) +static init_node_cpu_mask_v2(void) { int nnodes = numa_max_possible_node_v2_int() + 1; node_cpu_mask_v2 = calloc (nnodes, sizeof(struct bitmask *)); -- 1.9.1