aboutsummaryrefslogtreecommitdiffstats
diff options
authorMichael Kelley <mhklinux@outlook.com>2025-04-21 09:31:34 -0700
committerWei Liu <wei.liu@kernel.org>2025-04-25 21:13:53 +0000
commit14ae3003e73e777c9b36385a7c86f754b50a1821 (patch)
tree35fd7656680c2aeb45f7a314af0cea3854b8cb36
parent9bbb8a07fd65fca0f29a869ec3f2435761a6c676 (diff)
downloadlinux-hyperv-fixes.tar.gz
Drivers: hv: Fix bad ref to hv_synic_eventring_tail when CPU goes offlinehyperv-fixes-signed-20250427hyperv-fixes-staginghyperv-fixes
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: 04df7ac39943 ("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>
-rw-r--r--drivers/hv/hv_common.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
index a7d7494feaca13..59792e00cecf38 100644
--- a/drivers/hv/hv_common.c
+++ b/drivers/hv/hv_common.c
@@ -566,9 +566,11 @@ int hv_common_cpu_die(unsigned int cpu)
* originally allocated memory is reused in hv_common_cpu_init().
*/
- synic_eventring_tail = this_cpu_ptr(hv_synic_eventring_tail);
- kfree(*synic_eventring_tail);
- *synic_eventring_tail = NULL;
+ if (hv_root_partition()) {
+ synic_eventring_tail = this_cpu_ptr(hv_synic_eventring_tail);
+ kfree(*synic_eventring_tail);
+ *synic_eventring_tail = NULL;
+ }
return 0;
}