Skip to content

Commit 09406f2

Browse files
romank-msftliuw
authored andcommitted
Drivers: hv: Check message and event pages for non-NULL before iounmap()
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>
1 parent 1bb1532 commit 09406f2

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

drivers/hv/hv.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,10 @@ void hv_synic_disable_regs(unsigned int cpu)
371371
*/
372372
simp.simp_enabled = 0;
373373
if (ms_hyperv.paravisor_present || hv_root_partition()) {
374-
iounmap(hv_cpu->hyp_synic_message_page);
375-
hv_cpu->hyp_synic_message_page = NULL;
374+
if (hv_cpu->hyp_synic_message_page) {
375+
iounmap(hv_cpu->hyp_synic_message_page);
376+
hv_cpu->hyp_synic_message_page = NULL;
377+
}
376378
} else {
377379
simp.base_simp_gpa = 0;
378380
}
@@ -383,8 +385,10 @@ void hv_synic_disable_regs(unsigned int cpu)
383385
siefp.siefp_enabled = 0;
384386

385387
if (ms_hyperv.paravisor_present || hv_root_partition()) {
386-
iounmap(hv_cpu->hyp_synic_event_page);
387-
hv_cpu->hyp_synic_event_page = NULL;
388+
if (hv_cpu->hyp_synic_event_page) {
389+
iounmap(hv_cpu->hyp_synic_event_page);
390+
hv_cpu->hyp_synic_event_page = NULL;
391+
}
388392
} else {
389393
siefp.base_siefp_gpa = 0;
390394
}

0 commit comments

Comments
 (0)