提交 10e3148f 编写于 作者: J Jim Meyering

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.
上级 8343dcb8
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);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册