nvk: Fix segfault when opening DRI device file returns error

Previously, ver was unitialized on this path, causing UB on the
`if (ver)` branch after the out_err label.

Signed-off-by: Benjamin Lee <benjamin@computer.surgery>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
Benjamin Lee 2023-06-09 15:22:01 -07:00 committed by Marge Bot
parent 3572f5cd7e
commit 354fe8fda0

View file

@ -186,12 +186,13 @@ nouveau_ws_device_new(drmDevicePtr drm_device)
const char *path = drm_device->nodes[DRM_NODE_RENDER];
struct nouveau_ws_device *device = CALLOC_STRUCT(nouveau_ws_device);
uint64_t value = 0;
drmVersionPtr ver = NULL;
int fd = open(path, O_RDWR | O_CLOEXEC);
if (fd < 0)
goto out_err;
drmVersionPtr ver = drmGetVersion(fd);
ver = drmGetVersion(fd);
if (!ver)
goto out_err;