You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.5 KiB
47 lines
1.5 KiB
From ff6959fd9203c667f6b4c95fa812621cc91dc42e Mon Sep 17 00:00:00 2001
|
|
From: Jim Fehlig <jfehlig@suse.com>
|
|
Date: Tue, 14 Jan 2020 16:08:42 -0700
|
|
Subject: [PATCH 18/19] vhostmd: Fix memory leak in vhostmd_run
|
|
|
|
Example from coverity scan
|
|
|
|
vhostmd-1.1/vhostmd/vhostmd.c:940: alloc_arg: "vu_buffer_create" allocates memory that is stored into "buf".
|
|
vhostmd-1.1/vhostmd/vhostmd.c:959: leaked_storage: Variable "buf" going out of scope leaks the storage it points to.
|
|
957| vu_log(VHOSTMD_ERR, "Failed to start virtio thread '%s'\n",
|
|
958| strerror(rc));
|
|
959|-> return -1;
|
|
960| }
|
|
961| }
|
|
|
|
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
|
|
---
|
|
vhostmd/vhostmd.c | 5 ++++-
|
|
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/vhostmd/vhostmd.c b/vhostmd/vhostmd.c
|
|
index 1395bc5..6f3709b 100644
|
|
--- a/vhostmd/vhostmd.c
|
|
+++ b/vhostmd/vhostmd.c
|
|
@@ -967,14 +967,17 @@ static int vhostmd_run(int diskfd)
|
|
if (virtio_expiration_time < (update_period * 3))
|
|
virtio_expiration_time = update_period * 3;
|
|
|
|
- if (virtio_init(virtio_max_channels, virtio_expiration_time))
|
|
+ if (virtio_init(virtio_max_channels, virtio_expiration_time)) {
|
|
+ vu_buffer_delete(buf);
|
|
return -1;
|
|
+ }
|
|
|
|
rc = pthread_create(&virtio_tid, NULL, virtio_run, NULL);
|
|
|
|
if (rc != 0) {
|
|
vu_log(VHOSTMD_ERR, "Failed to start virtio thread '%s'\n",
|
|
strerror(rc));
|
|
+ vu_buffer_delete(buf);
|
|
return -1;
|
|
}
|
|
}
|
|
--
|
|
2.32.0
|
|
|