]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Drivers: hv: Check message and event pages for non-NULL before iounmap()
authorRoman Kisel <romank@linux.microsoft.com>
Wed, 8 Oct 2025 23:34:12 +0000 (16:34 -0700)
committerWei Liu <wei.liu@kernel.org>
Sat, 15 Nov 2025 06:18:15 +0000 (06:18 +0000)
It might happen that some hyp SynIC pages aren't allocated.

Check for that and only then call iounmap().

Signed-off-by: Roman Kisel <romank@linux.microsoft.com>
Reviewed-by: Tianyu Lan <tiala@microsoft.com>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Signed-off-by: Wei Liu <wei.liu@kernel.org>
drivers/hv/hv.c

index e9e1edd751079f1b213cbe9c4d72e8830afba1c5..77da2d2113789917ab86012aadb5dd1fa6108151 100644 (file)
@@ -371,8 +371,10 @@ void hv_synic_disable_regs(unsigned int cpu)
         */
        simp.simp_enabled = 0;
        if (ms_hyperv.paravisor_present || hv_root_partition()) {
-               iounmap(hv_cpu->hyp_synic_message_page);
-               hv_cpu->hyp_synic_message_page = NULL;
+               if (hv_cpu->hyp_synic_message_page) {
+                       iounmap(hv_cpu->hyp_synic_message_page);
+                       hv_cpu->hyp_synic_message_page = NULL;
+               }
        } else {
                simp.base_simp_gpa = 0;
        }
@@ -383,8 +385,10 @@ void hv_synic_disable_regs(unsigned int cpu)
        siefp.siefp_enabled = 0;
 
        if (ms_hyperv.paravisor_present || hv_root_partition()) {
-               iounmap(hv_cpu->hyp_synic_event_page);
-               hv_cpu->hyp_synic_event_page = NULL;
+               if (hv_cpu->hyp_synic_event_page) {
+                       iounmap(hv_cpu->hyp_synic_event_page);
+                       hv_cpu->hyp_synic_event_page = NULL;
+               }
        } else {
                siefp.base_siefp_gpa = 0;
        }