From ceb2551194b45f084a369ce9c5d69d11b3445ec8 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: (cherry picked from commit 7a81855a67526809d1ff2e3a70c7991e52948e3e) --- .pick_status.json | 2 +- src/freedreno/drm/freedreno_device.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index cc62b822a64..a29bfe77e7f 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1494,7 +1494,7 @@ "description": "freedreno/drm: don't crash for unsupported devices", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "48610676897d989ff8ce604022e7d611cec9c131", "notes": null 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