Commit 3f339f38 authored by Jakob Bornecrantz's avatar Jakob Bornecrantz
Browse files

vulkan-device-select: Don't leak drmDevicePtr



ASAN found a leak:

```
Direct leak of 1440 byte(s) in 10 object(s) allocated from:
    #0 0x4a9a92 in calloc (build-Monado-CMake/src/xrt/targets/service/monado-service+0x4a9a92)
    #1 0x7fdf82afed06 in drmDeviceAlloc build-drm/../drm/xf86drm.c:3933:14
    #2 0x7fdf82b00203 in drmProcessPciDevice build-drm/../drm/xf86drm.c:3965:11
    #3 0x7fdf82b00203 in process_device build-drm/../drm/xf86drm.c:4359:16
    #4 0x7fdf82b0485e in drmGetDevice2 build-drm/../drm/xf86drm.c:4528:15
    #5 0x7fdf70751113 in device_select_find_xcb_pci_default ../src/vulkan/device-select-layer/device_select_x11.c:95:13
    #6 0x7fdf70751113 in get_default_device ../src/vulkan/device-select-layer/device_select_layer.c:395:21
    #7 0x7fdf70751113 in device_select_EnumeratePhysicalDevices ../src/vulkan/device-select-layer/device_select_layer.c:456:33
```

Cc: mesa-stable
Reviewed-by: Bas Nieuwenhuizen's avatarBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: default avatarDave Airlie <airlied@redhat.com>
parent d4447848
Pipeline #459929 waiting for manual action with stages
......@@ -67,6 +67,8 @@ int device_select_find_xcb_pci_default(struct device_pci_info *devices, uint32_t
int scrn;
xcb_connection_t *conn;
int default_idx = -1;
drmDevicePtr xdev = NULL;
conn = xcb_connect(NULL, &scrn);
if (!conn)
return -1;
......@@ -91,7 +93,6 @@ int device_select_find_xcb_pci_default(struct device_pci_info *devices, uint32_t
if (dri3_fd == -1)
goto out;
drmDevicePtr xdev;
int ret = drmGetDevice2(dri3_fd, 0, &xdev);
close(dri3_fd);
if (ret < 0)
......@@ -113,7 +114,9 @@ int device_select_find_xcb_pci_default(struct device_pci_info *devices, uint32_t
if (default_idx != -1)
break;
}
out:
drmFreeDevice(&xdev); /* Is NULL pointer safe. */
xcb_disconnect(conn);
return default_idx;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment