Module Name: xsrc
Committed By: christos
Date: Fri Sep 21 18:33:08 UTC 2018
Modified Files:
xsrc/external/mit/libdrm/dist: xf86drm.c
Log Message:
- don't return random values to the caller
- don't leak fd's.
To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 xsrc/external/mit/libdrm/dist/xf86drm.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: xsrc/external/mit/libdrm/dist/xf86drm.c
diff -u xsrc/external/mit/libdrm/dist/xf86drm.c:1.20 xsrc/external/mit/libdrm/dist/xf86drm.c:1.21
--- xsrc/external/mit/libdrm/dist/xf86drm.c:1.20 Sat Sep 8 23:58:37 2018
+++ xsrc/external/mit/libdrm/dist/xf86drm.c Fri Sep 21 14:33:08 2018
@@ -3347,22 +3347,29 @@ static int drmParsePciDeviceInfo(int maj
if ((pcifd = open(fname, O_RDONLY)) == -1)
return -errno;
+ ret = -1;
/* Read the id and class pci config registers. */
if (pcibus_conf_read(pcifd, businfo.bus, businfo.dev, businfo.func,
PCI_ID_REG, &id) == -1)
- return -errno;
+ goto out;
if (pcibus_conf_read(pcifd, businfo.bus, businfo.dev, businfo.func,
PCI_CLASS_REG, &class) == -1)
- return -errno;
+ goto out;
if (pcibus_conf_read(pcifd, businfo.bus, businfo.dev, businfo.func,
PCI_SUBSYS_ID_REG, &subsys) == -1)
- return -errno;
+ goto out;
+ ret = 0;
device->vendor_id = PCI_VENDOR(id);
device->device_id = PCI_PRODUCT(id);
device->subvendor_id = PCI_SUBSYS_VENDOR(subsys);
device->subdevice_id = PCI_SUBSYS_ID(subsys);
device->revision_id = PCI_REVISION(class);
+out:
+ if (ret == -1)
+ ret = -errno;
+ close(pcifd);
+ return ret;
#elif defined(__OpenBSD__)
struct drm_pciinfo pinfo;
int fd, type;