Commit cb83b42e authored by Tejun Heo's avatar Tejun Heo

percpu: fix pcpu_chunk_struct_size

Impact: fix short allocation leading to memory corruption

While dropping rvalue wrapping macros around global parameters,
pcpu_chunk_struct_size was set incorrectly resulting in shorter page
pointer array.  Fix it.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent cae3aeb8
...@@ -850,7 +850,7 @@ size_t __init pcpu_setup_static(pcpu_populate_pte_fn_t populate_pte_fn, ...@@ -850,7 +850,7 @@ size_t __init pcpu_setup_static(pcpu_populate_pte_fn_t populate_pte_fn,
pcpu_chunk_size = num_possible_cpus() * pcpu_unit_size; pcpu_chunk_size = num_possible_cpus() * pcpu_unit_size;
pcpu_nr_slots = pcpu_size_to_slot(pcpu_unit_size) + 1; pcpu_nr_slots = pcpu_size_to_slot(pcpu_unit_size) + 1;
pcpu_chunk_struct_size = sizeof(struct pcpu_chunk) pcpu_chunk_struct_size = sizeof(struct pcpu_chunk)
+ (1 << pcpu_unit_pages_shift) * sizeof(struct page *); + num_possible_cpus() * pcpu_unit_pages * sizeof(struct page *);
/* allocate chunk slots */ /* allocate chunk slots */
pcpu_slot = alloc_bootmem(pcpu_nr_slots * sizeof(pcpu_slot[0])); pcpu_slot = alloc_bootmem(pcpu_nr_slots * sizeof(pcpu_slot[0]));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment