diff options
author | Eric Engestrom <eric@engestrom.ch> | 2021-08-13 21:19:13 +0100 |
---|---|---|
committer | Eric Engestrom <eric@engestrom.ch> | 2021-08-14 09:05:49 +0100 |
commit | 1a4c0ec9aea13211997f982715fe5ffcf19dd067 (patch) | |
tree | a207fb4affe5cba0469999b245323c499fdcfb2b /xf86drm.c | |
parent | 1d29e1df8b140b7ad3466d5122e703435ef5e436 (diff) |
xf86drm: fix mem leak in drm_usb_dev_path()
`sysfs_uevent_get()` returns a `strndup()`ed string, which must be `free()`d.
Fixes: bf63f8acdc94164ad29d ("libdrm: Handle usb_interface devices for usb parsing")
Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Diffstat (limited to 'xf86drm.c')
-rw-r--r-- | xf86drm.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -3998,6 +3998,7 @@ free_device: static int drm_usb_dev_path(int maj, int min, char *path, size_t len) { char *value, *tmp_path, *slash; + bool usb_device, usb_interface; snprintf(path, len, "/sys/dev/char/%d:%d/device", maj, min); @@ -4005,9 +4006,13 @@ static int drm_usb_dev_path(int maj, int min, char *path, size_t len) if (!value) return -ENOENT; - if (strcmp(value, "usb_device") == 0) + usb_device = strcmp(value, "usb_device") == 0; + usb_interface = strcmp(value, "usb_interface") == 0; + free(value); + + if (usb_device) return 0; - if (strcmp(value, "usb_interface") != 0) + if (!usb_interface) return -ENOTSUP; /* The parent of a usb_interface is a usb_device */ |