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.
54 lines
1.6 KiB
54 lines
1.6 KiB
From 855326a8c9ec1a599354f743fb5391a2766a2a9c Mon Sep 17 00:00:00 2001
|
|
From: Jim Fehlig <jfehlig@suse.com>
|
|
Date: Mon, 6 Jan 2020 17:47:10 -0700
|
|
Subject: [PATCH 06/19] libmetrics: Ensure libmetrics mutex is unlocked in
|
|
error paths
|
|
|
|
From coverity scan
|
|
|
|
vhostmd-1.1/libmetrics/libmetrics.c:595: missing_unlock: Returning without unlocking "libmetrics_mutex".
|
|
593| if (mdisk_alloc() == NULL) {
|
|
594| errno = ENOMEM;
|
|
595|-> return -1;
|
|
596| }
|
|
597| read_mdisk(mdisk);
|
|
|
|
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
|
|
---
|
|
libmetrics/libmetrics.c | 5 +++--
|
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/libmetrics/libmetrics.c b/libmetrics/libmetrics.c
|
|
index 2819f80..756645c 100644
|
|
--- a/libmetrics/libmetrics.c
|
|
+++ b/libmetrics/libmetrics.c
|
|
@@ -601,7 +601,7 @@ int get_metric(const char *metric_name, metric **mdef, metric_context context)
|
|
mdisk_free();
|
|
if (mdisk_alloc() == NULL) {
|
|
errno = ENOMEM;
|
|
- return -1;
|
|
+ goto out;
|
|
}
|
|
read_mdisk(mdisk);
|
|
}
|
|
@@ -620,7 +620,7 @@ int get_metric(const char *metric_name, metric **mdef, metric_context context)
|
|
|
|
if ((lmdef = metric_alloc_padded(extra_len)) == NULL) {
|
|
errno = ENOMEM;
|
|
- return -1;
|
|
+ goto out;
|
|
}
|
|
|
|
lmdef->type = pmdef.type;
|
|
@@ -635,6 +635,7 @@ int get_metric(const char *metric_name, metric **mdef, metric_context context)
|
|
if (pmdef.context)
|
|
free(pmdef.context);
|
|
|
|
+out:
|
|
/* unlock library data */
|
|
pthread_mutex_unlock(&libmetrics_mutex);
|
|
return ret;
|
|
--
|
|
2.32.0
|
|
|