drm/panthor: Fix NULL pointer dereference in sync signal cleanup
Subsystems (3)
PATCH 1/1 drm/panthor: Fix NULL pointer dereference in sync signal cleanup
In panthor_submit_ctx_add_sync_signal(), drm_syncobj_find() may return NULL. The function then jumps to err_free_sig_sync, where panthor_sync_signal_free() unconditionally calls drm_syncobj_put() on the NULL pointer, causing a NULL pointer dereference.
Check sig_sync->syncobj before calling drm_syncobj_put() to avoid the NULL pointer dereference.
--- drivers/gpu/drm/panthor/panthor_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/panthor/panthor_drv.c +3 -1
@@ -364,7 +364,9 @@ panthor_sync_signal_free(struct panthor_sync_signal *sig_sync)if (!sig_sync)return ; -drm_syncobj_put (sig_sync->syncobj); +if (sig_sync->syncobj) +drm_syncobj_put (sig_sync->syncobj); +dma_fence_chain_free (sig_sync->chain);dma_fence_put (sig_sync->fence);kfree (sig_sync);
Signature · 1 line
2.43.0
Quoted 7 lines · On Fri, 13 Nov 2026 17:44:56 +0800 Tuo Li <[email protected]> wrote:
In
panthor_submit_ctx_add_sync_signal(),drm_syncobj_find()may return NULL. The function then jumps toerr_free_sig_sync, wherepanthor_sync_signal_free()unconditionally callsdrm_syncobj_put()on the NULL pointer, causing a NULL pointer dereference.Check
sig_sync->syncobjbefore callingdrm_syncobj_put()to avoid the NULL pointer dereference.
I really wish we had consistent behavior on those _put() helpers. Most of them check for NULL before calling kref_put(), but some don't, unfortunately...
Quoted 3 lines
Fixes 4bdca1150792 ("drm/panthor: Add the driver frontend block")Signed-off-by Tuo Li <[email protected]>
Quoted 19 lines
--- drivers/gpu/drm/panthor/panthor_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/panthor/panthor_drv.c +3
-1@@ -364,7 +364,9 @@ panthor_sync_signal_free(struct panthor_sync_signal *sig_sync)if (!sig_sync)return ; -drm_syncobj_put (sig_sync->syncobj); +if (sig_sync->syncobj) +drm_syncobj_put (sig_sync->syncobj); +dma_fence_chain_free (sig_sync->chain);dma_fence_put (sig_sync->fence);kfree (sig_sync);
Quoted 10 lines · Tuo Li
In
panthor_submit_ctx_add_sync_signal(),drm_syncobj_find()may return NULL. The function then jumps toerr_free_sig_sync, wherepanthor_sync_signal_free()unconditionally callsdrm_syncobj_put()on the NULL pointer, causing a NULL pointer dereference.Check
sig_sync->syncobjbefore callingdrm_syncobj_put()to avoid the NULL pointer dereference.Fixes 4bdca1150792 ("drm/panthor: Add the driver frontend block")Signed-off-by Tuo Li <[email protected]>
Best regards,
Liviu
Quoted 22 lines
--- drivers/gpu/drm/panthor/panthor_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/panthor/panthor_drv.c +3
-1@@ -364,7 +364,9 @@ panthor_sync_signal_free(struct panthor_sync_signal *sig_sync)if (!sig_sync)return ; -drm_syncobj_put (sig_sync->syncobj); +if (sig_sync->syncobj) +drm_syncobj_put (sig_sync->syncobj); +dma_fence_chain_free (sig_sync->chain);dma_fence_put (sig_sync->fence);kfree (sig_sync);Signature · 1 line
2.43.0
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯