Skip to content

Commit 14ae300

Browse files
mhklinuxliuw
authored andcommitted
Drivers: hv: Fix bad ref to hv_synic_eventring_tail when CPU goes offline
When a CPU goes offline, hv_common_cpu_die() frees the hv_synic_eventring_tail memory for the CPU. But in a normal VM (i.e., not running in the root partition) the per-CPU memory has not been allocated, resulting in a bad memory reference and oops when computing the argument to kfree(). Fix this by freeing the memory only when running in the root partition. Fixes: 04df7ac ("Drivers: hv: Introduce per-cpu event ring tail") Signed-off-by: Michael Kelley <mhklinux@outlook.com> Reviewed-by: Nuno Das Neves <nunodasneves@linux.microsoft.com> Link: https://lore.kernel.org/r/20250421163134.2024-1-mhklinux@outlook.com Signed-off-by: Wei Liu <wei.liu@kernel.org> Message-ID: <20250421163134.2024-1-mhklinux@outlook.com>
1 parent 9bbb8a0 commit 14ae300

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/hv/hv_common.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,9 +566,11 @@ int hv_common_cpu_die(unsigned int cpu)
566566
* originally allocated memory is reused in hv_common_cpu_init().
567567
*/
568568

569-
synic_eventring_tail = this_cpu_ptr(hv_synic_eventring_tail);
570-
kfree(*synic_eventring_tail);
571-
*synic_eventring_tail = NULL;
569+
if (hv_root_partition()) {
570+
synic_eventring_tail = this_cpu_ptr(hv_synic_eventring_tail);
571+
kfree(*synic_eventring_tail);
572+
*synic_eventring_tail = NULL;
573+
}
572574

573575
return 0;
574576
}

0 commit comments

Comments
 (0)