Skip to content

Commit f230124

Browse files
authored
Merge pull request #247 from intel-innersource/release_resources_pci
Added missed closing for fd dev/pci
2 parents 429aa19 + 9d849bb commit f230124

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/pci.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ bool PciHandle::exists(uint32 groupnr_, uint32 bus_, uint32 device_, uint32 func
257257
struct pci_match_conf pattern;
258258
struct pci_conf conf[4];
259259
int fd;
260+
int ret;
260261

261262
fd = ::open("/dev/pci", O_RDWR, 0);
262263
if (fd < 0) return false;
@@ -274,7 +275,10 @@ bool PciHandle::exists(uint32 groupnr_, uint32 bus_, uint32 device_, uint32 func
274275
pc.match_buf_len = sizeof(conf);
275276
pc.matches = conf;
276277

277-
if (ioctl(fd, PCIOCGETCONF, &pc)) return false;
278+
ret = ioctl(fd, PCIOCGETCONF, &pc);
279+
::close(fd);
280+
281+
if (ret) return false;
278282

279283
if (pc.status != PCI_GETCONF_LAST_DEVICE) return false;
280284

0 commit comments

Comments
 (0)