summaryrefslogtreecommitdiffstats
path: root/lib/libkvm/kvm_amd64.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libkvm/kvm_amd64.c')
-rw-r--r--lib/libkvm/kvm_amd64.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libkvm/kvm_amd64.c b/lib/libkvm/kvm_amd64.c
index 70789f4..57a8728 100644
--- a/lib/libkvm/kvm_amd64.c
+++ b/lib/libkvm/kvm_amd64.c
@@ -118,7 +118,7 @@ _amd64_initvtop(kvm_t *kd)
amd64_pml4e_t *PML4;
kd->vmst = (struct vmstate *)_kvm_malloc(kd, sizeof(*kd->vmst));
- if (kd->vmst == 0) {
+ if (kd->vmst == NULL) {
_kvm_err(kd, kd->program, "cannot allocate vm");
return (-1);
}
@@ -153,6 +153,10 @@ _amd64_initvtop(kvm_t *kd)
}
pa = le64toh(pa);
PML4 = _kvm_malloc(kd, AMD64_PAGE_SIZE);
+ if (PML4 == NULL) {
+ _kvm_err(kd, kd->program, "cannot allocate PML4");
+ return (-1);
+ }
if (kvm_read2(kd, pa, PML4, AMD64_PAGE_SIZE) != AMD64_PAGE_SIZE) {
_kvm_err(kd, kd->program, "cannot read KPML4phys");
return (-1);
@@ -188,7 +192,7 @@ _amd64_vatop(kvm_t *kd, kvaddr_t va, off_t *pa)
* If we are initializing (kernel page table descriptor pointer
* not yet set) then return pa == va to avoid infinite recursion.
*/
- if (vm->PML4 == 0) {
+ if (vm->PML4 == NULL) {
s = _kvm_pa2off(kd, va, pa);
if (s == 0) {
_kvm_err(kd, kd->program,
OpenPOWER on IntegriCloud