Avoid panic when c.PCIDs is nil

When PCID is disabled, there would throw a panic
when dropPageTables() access to c.PCID without check.

Signed-off-by: Lai Jiangshan <eag0628@gmail.com>
This commit is contained in:
Lai Jiangshan
2020-01-09 09:18:33 +00:00
committed by Lai Jiangshan
parent d057871f41
commit fdfa05ff2c
2 changed files with 6 additions and 2 deletions
+3 -1
View File
@@ -90,7 +90,9 @@ func (m *machine) dropPageTables(pt *pagetables.PageTables) {
// Clear from all PCIDs.
for _, c := range m.vCPUs {
c.PCIDs.Drop(pt)
if c.PCIDs != nil {
c.PCIDs.Drop(pt)
}
}
}
+3 -1
View File
@@ -97,7 +97,9 @@ func (m *machine) dropPageTables(pt *pagetables.PageTables) {
// Clear from all PCIDs.
for _, c := range m.vCPUs {
c.PCIDs.Drop(pt)
if c.PCIDs != nil {
c.PCIDs.Drop(pt)
}
}
}