diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c
index 3c353c26f304e691638baf3c292324f149c9bc2a..78932e2baedab5d203167614114b247a0d4d9c6e 100644
--- a/drivers/gpu/drm/panfrost/panfrost_gem.c
+++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
@@ -75,17 +75,19 @@ static void panfrost_gem_mapping_release(struct kref *kref)
 				sg_free_table(&bo->sgts[i]);
 			}
 		}
+
+		drm_gem_shmem_put_pages(&bo->base);
 		kvfree(bo->sgts);
+		bo->sgts = NULL;
 	}
 
 	/* Pages ref is owned by the panfrost_gem_mapping object. We must
 	 * release our pages ref (if any), before releasing the object
 	 * ref.
 	 * Non-heap BOs acquired the pages at panfrost_gem_mapping creation
-	 * time, and heap BOs may have acquired pages if the fault handler
-	 * was called, in which case bo->sgts should be non-NULL.
+	 * time.
 	 */
-	if (!bo->base.base.import_attach && (!bo->is_heap || bo->sgts)) {
+	if (!bo->base.base.import_attach && !bo->is_heap && bo->sgts) {
 		drm_gem_shmem_put_pages(&bo->base);
 		bo->sgts = NULL;
 	}