Skip to content

Commit

Permalink
Avoid panic when c.PCIDs is nil
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
laijs authored and Lai Jiangshan committed Jan 9, 2020
1 parent d057871 commit fdfa05f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/sentry/platform/kvm/machine_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/sentry/platform/kvm/machine_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down

0 comments on commit fdfa05f

Please sign in to comment.