Re: [PATCH 0/2] drm/imagination: fix teardown use-after-free after removal

From: Ryan Brue

Date: Mon Nov 30 2026 - 12:07:05 EST


Hi Lewis,

On Wed, 25 Nov 2026 08:26:44 +0000, Lewis Lakerink wrote:
> Overlap with pending work:
> Ryan Brue's unmerged system-suspend series ("[PATCH v3 0/4]
> drm/imagination: fix system suspend, and the callback design underneath
> it") also moves pvr_watchdog_fini() and drm_dev_unplug() (guarded by
> !pvr_dev->lost) earlier in pvr_remove() (patches 2/4 and 3/4).

Thanks for this! I hit the postclose case on the same SoC (MT8173, GX6250) a couple of days ago. After the device was lost and then unbound and rebound while KWin still had the file open, closing it oopsed in pvr_vm_unmap_obj(), via postclose -> pvr_destroy_vm_contexts_for_file() -> pvr_vm_context_put() -> pvr_fw_object_destroy() -> pvr_meta_vm_unmap(). That kernel already had my v4 applied, which unplugs first in pvr_remove(), so unplugging earlier is not enough on its own - the drm_dev_enter() guard in postclose is the part that covers it.

I've now run your two patches on that board (v7.4-rc4 plus the board patches, lockdep on, and a local debug hook that marks the device lost from the watchdog). With glmark2 and KWin holding the device open, I unbound and rebound the GPU, then closed both:

- without your series, the close oopses in pvr_vm_unmap_obj() as above.
  with a device loss first, it crashes earlier, when pvr_remove() calls
  drm_dev_unplug() a second time;
- with your series, neither crashes, in both cases, and the GPU works
  after the rebind.

pvr_remove() still warns about objects that are alive at teardown (pvr_drv.c:1529, pvr_fw.c:1023, drm_mm_takedown(), pvr_context.c:549), as before. I don't think your series claims to change that.

Tested-by: Ryan Brue <ryanbrue.dev@xxxxxxxxx>

On the overlap: v4 is not posted yet. It and your series conflict in pvr_remove() whichever goes first, as you expected. I'm happy to rebase v4 onto yours if the maintainers would rather take yours first.

Best regards,
Ryan Brue