Auto-Merge pull request #2550 from octo/cid/179234
authorcollectd bot <32910397+collectd-bot@users.noreply.github.com>
Fri, 17 Nov 2017 15:44:07 +0000 (16:44 +0100)
committerGitHub <noreply@github.com>
Fri, 17 Nov 2017 15:44:07 +0000 (16:44 +0100)
Automatically merged due to "Automerge" label

src/ovs_stats.c

index 538386a..e7859da 100644 (file)
@@ -330,9 +330,10 @@ static int ovs_stats_update_bridge(yajl_val bridge) {
         br = ovs_stats_get_bridge(g_bridge_list_head, YAJL_GET_STRING(br_name));
         pthread_mutex_lock(&g_stats_lock);
         if (br == NULL) {
-          br = (bridge_list_t *)calloc(1, sizeof(bridge_list_t));
+          br = calloc(1, sizeof(*br));
           if (!br) {
-            ERROR("%s: Error allocating memory for bridge", plugin_name);
+            pthread_mutex_unlock(&g_stats_lock);
+            ERROR("%s: calloc(%zu) failed.", plugin_name, sizeof(*br));
             return -1;
           }
           char *tmp = YAJL_GET_STRING(br_name);
@@ -342,6 +343,7 @@ static int ovs_stats_update_bridge(yajl_val bridge) {
           if (br->name == NULL) {
             sfree(br);
             pthread_mutex_unlock(&g_stats_lock);
+            ERROR("%s: strdup failed.", plugin_name);
             return -1;
           }
           br->next = g_bridge_list_head;