Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a8709d4 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Ingo Molnar
Browse files

x86: uv - prevent NULL dereference in uv_system_init()



We may reach NULL dereference oops if kmalloc failed.
Prevent it with explicit BUG_ON.

[ Impact: more controlled assert in 'impossible' scenario ]

Signed-off-by: default avatarCyrill Gorcunov <gorcunov@openvz.org>
Acked-by: default avatarJack Steiner <steiner@sgi.com>
LKML-Reference: <20090501202511.GE4633@lenovo>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 1cbac972
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -569,15 +569,18 @@ void __init uv_system_init(void)


	bytes = sizeof(struct uv_blade_info) * uv_num_possible_blades();
	bytes = sizeof(struct uv_blade_info) * uv_num_possible_blades();
	uv_blade_info = kmalloc(bytes, GFP_KERNEL);
	uv_blade_info = kmalloc(bytes, GFP_KERNEL);
	BUG_ON(!uv_blade_info);


	get_lowmem_redirect(&lowmem_redir_base, &lowmem_redir_size);
	get_lowmem_redirect(&lowmem_redir_base, &lowmem_redir_size);


	bytes = sizeof(uv_node_to_blade[0]) * num_possible_nodes();
	bytes = sizeof(uv_node_to_blade[0]) * num_possible_nodes();
	uv_node_to_blade = kmalloc(bytes, GFP_KERNEL);
	uv_node_to_blade = kmalloc(bytes, GFP_KERNEL);
	BUG_ON(!uv_node_to_blade);
	memset(uv_node_to_blade, 255, bytes);
	memset(uv_node_to_blade, 255, bytes);


	bytes = sizeof(uv_cpu_to_blade[0]) * num_possible_cpus();
	bytes = sizeof(uv_cpu_to_blade[0]) * num_possible_cpus();
	uv_cpu_to_blade = kmalloc(bytes, GFP_KERNEL);
	uv_cpu_to_blade = kmalloc(bytes, GFP_KERNEL);
	BUG_ON(!uv_cpu_to_blade);
	memset(uv_cpu_to_blade, 255, bytes);
	memset(uv_cpu_to_blade, 255, bytes);


	blade = 0;
	blade = 0;