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: 4861067689 ("freedreno/drm: Add sub-allocator")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26961>
(cherry picked from commit 7a81855a67)
This commit is contained in:
Dmitry Baryshkov
2024-01-09 23:50:00 +02:00
committed by Eric Engestrom
parent 25aa495324
commit ceb2551194
2 changed files with 8 additions and 1 deletions

View File

@@ -1494,7 +1494,7 @@
"description": "freedreno/drm: don't crash for unsupported devices", "description": "freedreno/drm: don't crash for unsupported devices",
"nominated": true, "nominated": true,
"nomination_type": 1, "nomination_type": 1,
"resolution": 0, "resolution": 1,
"main_sha": null, "main_sha": null,
"because_sha": "48610676897d989ff8ce604022e7d611cec9c131", "because_sha": "48610676897d989ff8ce604022e7d611cec9c131",
"notes": null "notes": null

View File

@@ -104,6 +104,9 @@ out:
if (!use_heap) { if (!use_heap) {
struct fd_pipe *pipe = fd_pipe_new(dev, FD_PIPE_3D); 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 /* Userspace fences don't appear to be reliable enough (missing some
* cache flushes?) on older gens, so limit sub-alloc heaps to a6xx+ * cache flushes?) on older gens, so limit sub-alloc heaps to a6xx+
* for now: * for now:
@@ -119,6 +122,10 @@ out:
} }
return dev; return dev;
fail:
fd_device_del(dev);
return NULL;
} }
/* like fd_device_new() but creates it's own private dup() of the fd /* like fd_device_new() but creates it's own private dup() of the fd