From: Benjamin Lee Date: Fri, 9 Jun 2023 22:22:01 +0000 (-0700) Subject: nvk: Fix segfault when opening DRI device file returns error X-Git-Tag: upstream/23.3.3~3867 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=354fe8fda01d0803dba918d8e2ca53b07b60b757;p=platform%2Fupstream%2Fmesa.git 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: --- 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;