mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
avoid file descriptor leak when fd == 0
* src/pci.c (pciGetDevice): Initialize dev->fd to -1, not 0. (pciFreeDevice): Close fd also when it is 0.
This commit is contained in:
parent
8343dcb893
commit
10e3148f0a
@ -1,3 +1,9 @@
|
||||
Tue Mar 3 12:22:51 +0100 2009 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
avoid file descriptor leak when fd == 0
|
||||
* src/pci.c (pciGetDevice): Initialize dev->fd to -1, not 0.
|
||||
(pciFreeDevice): Close fd also when it is 0.
|
||||
|
||||
Tue Mar 3 12:22:51 +0100 2009 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
don't leak a file descriptor on failed pciGetDevice call
|
||||
|
@ -789,6 +789,7 @@ pciGetDevice(virConnectPtr conn,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dev->fd = -1;
|
||||
dev->domain = domain;
|
||||
dev->bus = bus;
|
||||
dev->slot = slot;
|
||||
@ -827,7 +828,7 @@ void
|
||||
pciFreeDevice(virConnectPtr conn ATTRIBUTE_UNUSED, pciDevice *dev)
|
||||
{
|
||||
VIR_DEBUG("%s %s: freeing", dev->id, dev->name);
|
||||
if (dev->fd)
|
||||
if (dev->fd >= 0)
|
||||
close(dev->fd);
|
||||
VIR_FREE(dev);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user