Whamcloud - gitweb
LU-5751 libcfs: check mask returned by cpumask_of_node 07/13207/2
authorLiang Zhen <liang.zhen@intel.com>
Tue, 30 Dec 2014 15:44:11 +0000 (23:44 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 7 Jan 2015 17:14:00 +0000 (17:14 +0000)
cpumask_of_node can return NULL if NUMA node is unavailable,
in this case cfs_node_to_cpumask will try to copy from NULL
and cause kernel panic.

Signed-off-by: Liang Zhen <liang.zhen@intel.com>
Change-Id: Ia866c80a5cf5eaba76e392daa77a572fd427d18c
Reviewed-on: http://review.whamcloud.com/13207
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Li Wei <wei.g.li@intel.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/libcfs/linux/linux-cpu.c

index 2da255e..ea0b087 100644 (file)
@@ -130,7 +130,12 @@ EXPORT_SYMBOL(cfs_cpu_ht_nsiblings);
 void
 cfs_node_to_cpumask(int node, cpumask_t *mask)
 {
-       cpumask_copy(mask, cpumask_of_node(node));
+       const cpumask_t *tmp = cpumask_of_node(node);
+
+       if (tmp != NULL)
+               cpumask_copy(mask, tmp);
+       else
+               cpumask_clear(mask);
 }
 EXPORT_SYMBOL(cfs_node_to_cpumask);