xf86drm: Check non-absolute path only for virtio based devices
This fixes bug in drmParseSubsystemType() that cases situation when subsequent call to readlink() from get_subsystem_type() will result in EACCESS. Signed-off-by: Mikhail Golubev <mikhail.golubev@opensynergy.com>main
parent
9001c93b7f
commit
57df07572c
12
xf86drm.c
12
xf86drm.c
|
@ -3103,15 +3103,18 @@ static int drmParseSubsystemType(int maj, int min)
|
||||||
int subsystem_type;
|
int subsystem_type;
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device", maj, min);
|
snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device", maj, min);
|
||||||
if (!realpath(path, real_path))
|
|
||||||
return -errno;
|
|
||||||
snprintf(path, sizeof(path), "%s", real_path);
|
|
||||||
|
|
||||||
subsystem_type = get_subsystem_type(path);
|
subsystem_type = get_subsystem_type(path);
|
||||||
|
/* Try to get the parent (underlying) device type */
|
||||||
if (subsystem_type == DRM_BUS_VIRTIO) {
|
if (subsystem_type == DRM_BUS_VIRTIO) {
|
||||||
|
/* Assume virtio-pci on error */
|
||||||
|
if (!realpath(path, real_path))
|
||||||
|
return DRM_BUS_VIRTIO;
|
||||||
strncat(path, "/..", PATH_MAX);
|
strncat(path, "/..", PATH_MAX);
|
||||||
subsystem_type = get_subsystem_type(path);
|
subsystem_type = get_subsystem_type(path);
|
||||||
}
|
if (subsystem_type < 0)
|
||||||
|
return DRM_BUS_VIRTIO;
|
||||||
|
}
|
||||||
return subsystem_type;
|
return subsystem_type;
|
||||||
#elif defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__)
|
#elif defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__)
|
||||||
return DRM_BUS_PCI;
|
return DRM_BUS_PCI;
|
||||||
|
@ -3920,6 +3923,7 @@ process_device(drmDevicePtr *device, const char *d_name,
|
||||||
|
|
||||||
switch (subsystem_type) {
|
switch (subsystem_type) {
|
||||||
case DRM_BUS_PCI:
|
case DRM_BUS_PCI:
|
||||||
|
case DRM_BUS_VIRTIO:
|
||||||
return drmProcessPciDevice(device, node, node_type, maj, min,
|
return drmProcessPciDevice(device, node, node_type, maj, min,
|
||||||
fetch_deviceinfo, flags);
|
fetch_deviceinfo, flags);
|
||||||
case DRM_BUS_USB:
|
case DRM_BUS_USB:
|
||||||
|
|
Loading…
Reference in New Issue