Skip to content

Commit

Permalink
core/cpu: Fix memory allocation for job array
Browse files Browse the repository at this point in the history
fixes: 7a3f307 core/cpu: parallelise global CPU register setting jobs

This bug would result in boot-hang on some configurations due to
cpu_wait_job() endlessly waiting for the last bogus jobs[cpu->pir] pointer.

Reported-by: Stephanie Swanson <swanman@us.ibm.com>
Reported-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Reviewed-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
svaidy authored and stewartsmith committed Sep 13, 2018
1 parent 084e37b commit df5da05
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,7 @@ static int64_t cpu_change_all_hid0(struct hid0_change_req *req)
struct cpu_thread *cpu;
struct cpu_job **jobs;

jobs = zalloc(sizeof(struct cpu_job *) * cpu_max_pir + 1);
jobs = zalloc(sizeof(struct cpu_job *) * (cpu_max_pir + 1));
assert(jobs);

for_each_available_cpu(cpu) {
Expand Down Expand Up @@ -1424,7 +1424,7 @@ static int64_t cpu_cleanup_all(void)
struct cpu_thread *cpu;
struct cpu_job **jobs;

jobs = zalloc(sizeof(struct cpu_job *) * cpu_max_pir + 1);
jobs = zalloc(sizeof(struct cpu_job *) * (cpu_max_pir + 1));
assert(jobs);

for_each_available_cpu(cpu) {
Expand Down

0 comments on commit df5da05

Please sign in to comment.