From be574169c1f5f428b9657b3df3313016a5e73066 Mon Sep 17 00:00:00 2001 From: Felix Kuehling Date: Fri, 7 Sep 2018 17:21:37 -0400 Subject: [PATCH] libhsakmt: Fix segfault on gfx801 Handle the case that svm.dgpu_aperture does not exist in vm_find_object. Change-Id: Ic0983d4f321f1b6248514f2fa25162976e90bd75 Signed-off-by: Felix Kuehling --- src/fmm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/fmm.c b/src/fmm.c index 24ddddcd5e..223ff364af 100644 --- a/src/fmm.c +++ b/src/fmm.c @@ -1033,6 +1033,9 @@ static vm_object_t *vm_find_object(const void *addr, uint64_t size, } if (!aper) { + if (!svm.dgpu_aperture) + goto no_svm; + if ((addr >= svm.dgpu_aperture->base) && (addr <= svm.dgpu_aperture->limit)) aper = svm.dgpu_aperture; @@ -1075,9 +1078,11 @@ static vm_object_t *vm_find_object(const void *addr, uint64_t size, } } +no_svm: if (!obj && !is_dgpu) { /* On APUs try finding it in the CPUVM aperture */ - pthread_mutex_unlock(&aper->fmm_mutex); + if (aper) + pthread_mutex_unlock(&aper->fmm_mutex); aper = &cpuvm_aperture; @@ -1093,7 +1098,8 @@ static vm_object_t *vm_find_object(const void *addr, uint64_t size, return obj; } - pthread_mutex_unlock(&aper->fmm_mutex); + if (aper) + pthread_mutex_unlock(&aper->fmm_mutex); return NULL; }