From 7a81855a67526809d1ff2e3a70c7991e52948e3e Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Tue, 9 Jan 2024 23:50:00 +0200 Subject: [PATCH] freedreno/drm: don't crash for unsupported devices For unsupported devices fd_pipe_new() will return NULL, causing a crash when fd_device_new() tries to check device generation. Handle fd_pipe_new() returning NULL by destroying device and returning NULL. Fixes: 48610676897d ("freedreno/drm: Add sub-allocator") Signed-off-by: Dmitry Baryshkov Part-of: --- src/freedreno/drm/freedreno_device.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/freedreno/drm/freedreno_device.c b/src/freedreno/drm/freedreno_device.c index cff09fd8fbb..367e499b732 100644 --- a/src/freedreno/drm/freedreno_device.c +++ b/src/freedreno/drm/freedreno_device.c @@ -104,6 +104,9 @@ out: if (!use_heap) { struct fd_pipe *pipe = fd_pipe_new(dev, FD_PIPE_3D); + if (!pipe) + goto fail; + /* Userspace fences don't appear to be reliable enough (missing some * cache flushes?) on older gens, so limit sub-alloc heaps to a6xx+ * for now: @@ -119,6 +122,10 @@ out: } return dev; + +fail: + fd_device_del(dev); + return NULL; } /* like fd_device_new() but creates it's own private dup() of the fd