[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 35/38] piix: fix resource leak reported by Coverity
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 35/38] piix: fix resource leak reported by Coverity |
Date: |
Wed, 21 Oct 2015 13:28:37 +0300 |
From: zhanghailiang <address@hidden>
config_fd should be closed before return, or there will
be a resource leak error.
Signed-off-by: zhanghailiang <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
hw/pci-host/piix.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index 1fb71c8..7b2fbf9 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -764,6 +764,7 @@ static int host_pci_config_read(int pos, int len, uint32_t
val)
/* Access real host bridge. */
int rc = snprintf(path, size, "/sys/bus/pci/devices/%04x:%02x:%02x.%d/%s",
0, 0, 0, 0, "config");
+ int ret = 0;
if (rc >= size || rc < 0) {
return -ENODEV;
@@ -775,16 +776,18 @@ static int host_pci_config_read(int pos, int len,
uint32_t val)
}
if (lseek(config_fd, pos, SEEK_SET) != pos) {
- return -errno;
+ ret = -errno;
+ goto out;
}
do {
rc = read(config_fd, (uint8_t *)&val, len);
} while (rc < 0 && (errno == EINTR || errno == EAGAIN));
if (rc != len) {
- return -errno;
+ ret = -errno;
}
-
- return 0;
+out:
+ close(config_fd);
+ return ret;
}
static int igd_pt_i440fx_initfn(struct PCIDevice *pci_dev)
--
MST
- [Qemu-devel] [PULL 25/38] vhost user: add rarp sending after live migration for legacy guest, (continued)
- [Qemu-devel] [PULL 25/38] vhost user: add rarp sending after live migration for legacy guest, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 26/38] vhost-user: use an enum helper for features mask, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 27/38] vhost: add migration block if memfd failed, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 28/38] vhost-user-test: move wait_for_fds() out, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 29/38] vhost-user-test: remove useless static check, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 30/38] vhost-user-test: wrap server in TestServer struct, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 31/38] vhost-user-test: learn to tweak various qemu arguments, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 32/38] vhost-user-test: add live-migration test, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 33/38] vhost-user-test: check ownership during migration, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 34/38] seccomp: add memfd_create to whitelist, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 35/38] piix: fix resource leak reported by Coverity,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 36/38] vhost: set the correct queue index in case of migration with multiqueue, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 38/38] hw/isa/lpc_ich9: inject the SMI on the VCPU that is writing to APM_CNT, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 37/38] i386: keep cpu_model field in MachineState uptodate, Michael S. Tsirkin, 2015/10/21
- Re: [Qemu-devel] [PULL 00/38] vhost, pc, virtio features, fixes, cleanups, Peter Maydell, 2015/10/21