summaryrefslogtreecommitdiff
path: root/drivers/bus
diff options
context:
space:
mode:
authorStephen Hemminger <stephen@networkplumber.org>2018-11-06 11:30:03 -0800
committerThomas Monjalon <thomas@monjalon.net>2018-11-14 02:13:56 +0100
commit6521c9a2f7e00b0fcee940e0570ee12fcd9ca8dc (patch)
tree18971d1b96f35a90662232690d40e638bc36b8c4 /drivers/bus
parent6927f8dbf3db975cd968287c511122ddccc076bb (diff)
downloaddpdk-next-eventdev-6521c9a2f7e00b0fcee940e0570ee12fcd9ca8dc.zip
dpdk-next-eventdev-6521c9a2f7e00b0fcee940e0570ee12fcd9ca8dc.tar.gz
dpdk-next-eventdev-6521c9a2f7e00b0fcee940e0570ee12fcd9ca8dc.tar.xz
bus/vmbus: fix directory handle leak on error
If sysfs directory was incorrectly formatted then the vmbus setup code would leak a directory handle in the error path. Coverity issue: 302848 Fixes: 831dba47bd36 ("bus/vmbus: add Hyper-V virtual bus support") Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Diffstat (limited to 'drivers/bus')
-rw-r--r--drivers/bus/vmbus/linux/vmbus_uio.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c
index 856c6d6..12e97e3 100644
--- a/drivers/bus/vmbus/linux/vmbus_uio.c
+++ b/drivers/bus/vmbus/linux/vmbus_uio.c
@@ -329,6 +329,7 @@ int vmbus_uio_get_subchan(struct vmbus_channel *primary,
char chan_path[PATH_MAX], subchan_path[PATH_MAX];
struct dirent *ent;
DIR *chan_dir;
+ int err;
snprintf(chan_path, sizeof(chan_path),
"%s/%s/channels",
@@ -344,7 +345,6 @@ int vmbus_uio_get_subchan(struct vmbus_channel *primary,
while ((ent = readdir(chan_dir))) {
unsigned long relid, subid, monid;
char *endp;
- int err;
if (ent->d_name[0] == '.')
continue;
@@ -364,8 +364,7 @@ int vmbus_uio_get_subchan(struct vmbus_channel *primary,
if (err) {
VMBUS_LOG(NOTICE, "invalid subchannel id %lu",
subid);
- closedir(chan_dir);
- return err;
+ goto fail;
}
if (subid == 0)
@@ -382,17 +381,20 @@ int vmbus_uio_get_subchan(struct vmbus_channel *primary,
if (err) {
VMBUS_LOG(NOTICE, "invalid monitor id %lu",
monid);
- return err;
+ goto fail;
}
err = vmbus_chan_create(dev, relid, subid, monid, subchan);
if (err) {
VMBUS_LOG(NOTICE, "subchannel setup failed");
- return err;
+ goto fail;
}
break;
}
closedir(chan_dir);
return (ent == NULL) ? -ENOENT : 0;
+fail:
+ closedir(chan_dir);
+ return err;
}