Răsfoiți Sursa

totemconfig: Free leaks found by coverity

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Jan Friesse 6 ani în urmă
părinte
comite
efe48120e2
1 a modificat fișierele cu 17 adăugiri și 9 ștergeri
  1. 17 9
      exec/totemconfig.c

+ 17 - 9
exec/totemconfig.c

@@ -470,6 +470,8 @@ static int totem_volatile_config_validate (
 					  "for a multi-link configuration, all nodes must have a 'name' attribute");
 					  "for a multi-link configuration, all nodes must have a 'name' attribute");
 				goto parse_error;
 				goto parse_error;
 			}
 			}
+
+			free(name_str);
 		}
 		}
 
 
 		for (i=0; i < INTERFACE_MAX; i++) {
 		for (i=0; i < INTERFACE_MAX; i++) {
@@ -1445,6 +1447,7 @@ static int get_interface_params(struct totem_config *totem_config,
 	char *str;
 	char *str;
 	char *cluster_name = NULL;
 	char *cluster_name = NULL;
 	enum totem_ip_version_enum tmp_ip_version = TOTEM_IP_VERSION_4;
 	enum totem_ip_version_enum tmp_ip_version = TOTEM_IP_VERSION_4;
+	int ret = 0;
 
 
 	if (reload) {
 	if (reload) {
 		for (i=0; i<INTERFACE_MAX; i++) {
 		for (i=0; i<INTERFACE_MAX; i++) {
@@ -1479,14 +1482,13 @@ static int get_interface_params(struct totem_config *totem_config,
 		linknumber = atoi(linknumber_key);
 		linknumber = atoi(linknumber_key);
 
 
 		if (linknumber >= INTERFACE_MAX) {
 		if (linknumber >= INTERFACE_MAX) {
-			free(cluster_name);
-
 			snprintf (error_string_response, sizeof(error_string_response),
 			snprintf (error_string_response, sizeof(error_string_response),
 			    "parse error in config: interface ring number %u is bigger than allowed maximum %u\n",
 			    "parse error in config: interface ring number %u is bigger than allowed maximum %u\n",
 			    linknumber, INTERFACE_MAX - 1);
 			    linknumber, INTERFACE_MAX - 1);
 
 
 			*error_string = error_string_response;
 			*error_string = error_string_response;
-			return -1;
+			ret = -1;
+			goto out;
 		}
 		}
 
 
 		/* These things are only valid for the initial read */
 		/* These things are only valid for the initial read */
@@ -1505,7 +1507,8 @@ static int get_interface_params(struct totem_config *totem_config,
 					*error_string = error_string_response;
 					*error_string = error_string_response;
 					free(str);
 					free(str);
 
 
-					return -1;
+					ret = -1;
+					goto out;
 				}
 				}
 
 
 				free(str);
 				free(str);
@@ -1524,7 +1527,8 @@ static int get_interface_params(struct totem_config *totem_config,
 					*error_string = error_string_response;
 					*error_string = error_string_response;
 					free(str);
 					free(str);
 
 
-					return -1;
+					ret = -1;
+					goto out;
 				}
 				}
 
 
 				free(str);
 				free(str);
@@ -1594,7 +1598,8 @@ static int get_interface_params(struct totem_config *totem_config,
 				}
 				}
 				else {
 				else {
 					*error_string = "Unrecognised knet_transport. expected 'udp' or 'sctp'";
 					*error_string = "Unrecognised knet_transport. expected 'udp' or 'sctp'";
-					return -1;
+					ret = -1;
+					goto out;
 				}
 				}
 			}
 			}
 		}
 		}
@@ -1652,9 +1657,9 @@ static int get_interface_params(struct totem_config *totem_config,
 					*error_string = error_string_response;
 					*error_string = error_string_response;
 
 
 					icmap_iter_finalize(member_iter);
 					icmap_iter_finalize(member_iter);
-					icmap_iter_finalize(iter);
 					free(str);
 					free(str);
-					return -1;
+					ret = -1;
+					goto out;
 				}
 				}
 
 
 				free(str);
 				free(str);
@@ -1665,9 +1670,12 @@ static int get_interface_params(struct totem_config *totem_config,
 		totem_config->interfaces[linknumber].member_count = member_count;
 		totem_config->interfaces[linknumber].member_count = member_count;
 
 
 	}
 	}
+
+out:
 	icmap_iter_finalize(iter);
 	icmap_iter_finalize(iter);
+	free(cluster_name);
 
 
-	return 0;
+	return (ret);
 }
 }
 
 
 extern int totem_config_read (
 extern int totem_config_read (