From 354fe8fda01d0803dba918d8e2ca53b07b60b757 Mon Sep 17 00:00:00 2001 From: Benjamin Lee Date: Fri, 9 Jun 2023 15:22:01 -0700 Subject: [PATCH] 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 Part-of: --- src/nouveau/winsys/nouveau_device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nouveau/winsys/nouveau_device.c b/src/nouveau/winsys/nouveau_device.c index 2cc9ad5..dfade7e 100644 --- a/src/nouveau/winsys/nouveau_device.c +++ b/src/nouveau/winsys/nouveau_device.c @@ -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; -- 2.7.4