Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Pre-existing issues: - [High] Missing DRM unplug protection in IOCTL handlers allows Use-After-Unmap of MMIO resources. - [High] The plane atomic update callback calls multiple sleeping functions while executing in atomic context. - [High] Premature shared IRQ registration causes a NULL pointer dereference if the interrupt fires before CRTC initialization. -- --- Patch [3]: [RFC PATCH 3/3] NOT FOR MERGE: drm/glanda: Add x86 platform test device --- commit 6108d4cd0cea176f9e750373bc9ba705d3d2a6c7 Author: Leander Kieweg <[email protected]> NOT FOR MERGE: drm/glanda: Add x86 platform test device Register a mock platform device on x86 architectures to allow testing the GlandaGPU driver inside QEMU without cross-compiling. > diff --git a/drivers/gpu/drm/tiny/glandagpu.c > b/drivers/gpu/drm/tiny/glandagpu.c > index 8f87ae096a2e3..c1e9370f2a4b1 100644 > --- a/drivers/gpu/drm/tiny/glandagpu.c > +++ b/drivers/gpu/drm/tiny/glandagpu.c [Severity: High] This is a pre-existing issue, but is it possible for a concurrent ioctl to access unmapped MMIO memory during device removal? Looking at glandagpu_remove(), it wakes up blocked ioctls: drivers/gpu/drm/tiny/glandagpu.c:glandagpu_remove() { ... gdev->cmd_done = true; wake_up_interruptible(&gdev->cmd_wq); ... } However, it lacks drm_dev_unplug() and drm_dev_enter()/drm_dev_exit() synchronization. When glandagpu_remove() returns, the devres framework automatically unmaps gdev->mmio_base. The forcibly awakened ioctl could then resume and write directly to the unmapped MMIO memory: drivers/gpu/drm/tiny/glandagpu.c:glanda_hw_clear() { ... writel(color, gdev->mmio_base + REG_COLOR); ... } Could this cause a kernel panic due to a use-after-unmap page fault? [Severity: High] This isn't a bug introduced by this patch, but does the plane atomic update callback sleep while in atomic context? Userspace can initiate a non-blocking DRM atomic commit, which executes glanda_plane_atomic_update() in an atomic context. However, it appears to call multiple sleeping functions: drivers/gpu/drm/tiny/glandagpu.c:glanda_plane_atomic_update() { ... dma_resv_lock(shmem->base.resv, NULL); ret = drm_gem_shmem_vmap_locked(shmem, &map); ... mutex_lock(&gdev->lock); ret = glanda_wait_idle(gdev); ... } Since glanda_wait_idle() internally uses wait_event_interruptible_timeout(), could these calls cause system instability, scheduling-while-atomic warnings, or deadlocks in the DRM commit worker? [Severity: High] This is a pre-existing issue, but could premature shared IRQ registration cause a NULL pointer dereference during probe? In glandagpu_probe(), devm_request_irq() is called with IRQF_SHARED before the DRM CRTC is initialized by drm_crtc_init_with_planes(): drivers/gpu/drm/tiny/glandagpu.c:glandagpu_probe() { ... ret = devm_request_irq(&pdev->dev, gdev->irq, glanda_irq_handler, IRQF_SHARED, "glandagpu", gdev); ... ret = drm_crtc_init_with_planes(&gdev->drm, &gdev->crtc, ... } If another device on the same shared line triggers an interrupt immediately, the handler reads the raw REG_ISR without masking it against the interrupt enable register (REG_IER). If the INT_VSYNC bit is set, it proceeds to handle the vblank: drivers/gpu/drm/tiny/glandagpu.c:glanda_irq_handler() { ... if (isr & INT_VSYNC) drm_crtc_handle_vblank(&gdev->crtc); ... } Since gdev->crtc is still zero-initialized at this point, could this dereference a NULL crtc->dev pointer and lead to a kernel panic? -- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
