mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-07 02:10:12 +01:00
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 <bas@basnieuwenhuizen.nl>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14068>
(cherry picked from commit 555f93cdcd)
This commit is contained in:
parent
26a01fc07a
commit
4b38a272b6
2 changed files with 5 additions and 2 deletions
|
|
@ -3901,7 +3901,7 @@
|
|||
"description": "vulkan-device-select: Don't leak drmDevicePtr",
|
||||
"nominated": true,
|
||||
"nomination_type": 0,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue