Skip to content

Commit f70744c

Browse files
rmurphy-armrobherring
authored andcommitted
drm/panfrost: Don't dereference bogus MMU pointers
It seems that killing an application while faults are occurring (particularly with a GPU in FPGA at a whopping 40MHz) can lead to handling a lingering page fault after all the address space contexts have already been freed. In this situation, the LRU list is empty so addr_to_drm_mm_node() ends up dereferencing the list head as if it were a struct panfrost_mmu entry; this leaves "mmu->as" actually pointing at the pfdev->alloc_mask bitmap, which is also empty, and given that the fault has a high likelihood of being in AS0, hilarity ensues. Sadly, the cleanest solution seems to involve another goto. Oh well, at least it's robust... Fixes: 65e51e3 ("drm/panfrost: Prevent race when handling page fault") Signed-off-by: Robin Murphy <[email protected]> Signed-off-by: Rob Herring <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/9a0b09e6b5851f0d4428b72dd6b8b4c0d0ef4206.1572293305.git.robin.murphy@arm.com
1 parent 6f39188 commit f70744c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/gpu/drm/panfrost/panfrost_mmu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,11 @@ addr_to_drm_mm_node(struct panfrost_device *pfdev, int as, u64 addr)
406406
spin_lock(&pfdev->as_lock);
407407
list_for_each_entry(mmu, &pfdev->as_lru_list, list) {
408408
if (as == mmu->as)
409-
break;
409+
goto found_mmu;
410410
}
411-
if (as != mmu->as)
412-
goto out;
411+
goto out;
413412

413+
found_mmu:
414414
priv = container_of(mmu, struct panfrost_file_priv, mmu);
415415

416416
spin_lock(&priv->mm_lock);

0 commit comments

Comments
 (0)