Skip to content

Commit

Permalink
smp_ihk_release_cpu: Fix error handling
Browse files Browse the repository at this point in the history
* Range-check CPU ID
* Error-return when trying to online onlined CPU

Change-Id: I437d3046333e54e7525d41c2d2ab1006846d003e
  • Loading branch information
masamichitakagi committed Jan 31, 2020
1 parent fdd513f commit b96efcf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion linux/driver/smp/smp-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -3716,6 +3716,13 @@ static int smp_ihk_release_cpu(ihk_device_t ihk_dev, unsigned long arg)
memset(&cpus_to_online, 0, sizeof(cpus_to_online));

for (i = 0; i < req.num_cpus; i++) {
if (req_cpus[i] < 0 || req_cpus[i] >= nr_cpu_ids) {
pr_info("%s: error: CPU %d is out of range\n",
__func__, req_cpus[i]);

ret = -EINVAL;
goto out;
}
cpumask_set_cpu(req_cpus[i], &cpus_to_online);
}

Expand All @@ -3740,7 +3747,10 @@ static int smp_ihk_release_cpu(ihk_device_t ihk_dev, unsigned long arg)
}

if (cpu_online(cpu)) {
continue;
printk("IHK-SMP: error: CPU %d is online\n",
cpu);
ret = -EINVAL;
goto err;
}

if (ihk_smp_cpus[cpu].status != IHK_SMP_CPU_AVAILABLE) {
Expand Down

0 comments on commit b96efcf

Please sign in to comment.