Skip to content

Commit b0ecec6

Browse files
committed
Add missing frees in argument parsing
1 parent bec9264 commit b0ecec6

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/dp_conf.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ int dp_conf_parse_file(const char *env_filename)
327327
void dp_conf_free(void)
328328
{
329329
free(dhcp_dns.array);
330+
free(dhcpv6_dns.array);
330331
#ifdef ENABLE_VIRTSVC
331332
free(virtual_services.entries);
332333
#endif

src/dp_service.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ static char **dp_argv;
3434
static int dp_argc;
3535
static char *dp_mlx_args[4];
3636

37+
static void dp_args_free_mellanox(void)
38+
{
39+
for (int i = 0; i < 4; ++i)
40+
free(dp_mlx_args[i]);
41+
free(dp_argv);
42+
}
43+
3744
static int dp_args_add_mellanox(int *orig_argc, char ***orig_argv)
3845
{
3946
int curarg;
@@ -69,6 +76,7 @@ static int dp_args_add_mellanox(int *orig_argc, char ***orig_argv)
6976
}
7077
if (!dp_mlx_args[0] || !dp_mlx_args[1] || !dp_mlx_args[2] || !dp_mlx_args[3]) {
7178
DP_EARLY_ERR("Cannot allocate Mellanox arguments");
79+
dp_args_free_mellanox();
7280
return DP_ERROR;
7381
}
7482

@@ -85,13 +93,6 @@ static int dp_args_add_mellanox(int *orig_argc, char ***orig_argv)
8593
return DP_OK;
8694
}
8795

88-
static void dp_args_free_mellanox(void)
89-
{
90-
for (int i = 0; i < 4; ++i)
91-
free(dp_mlx_args[i]);
92-
free(dp_argv);
93-
}
94-
9596
static bool dp_is_mellanox_opt_set(void)
9697
{
9798
return dp_conf_get_eal_a_pf0()[0] != '\0'
@@ -268,6 +269,7 @@ int main(int argc, char **argv)
268269
eal_argcount = dp_eal_init(&argc, &argv);
269270
if (DP_FAILED(eal_argcount)) {
270271
DP_EARLY_ERR("Failed to initialize EAL");
272+
dp_conf_free();
271273
return EXIT_FAILURE;
272274
}
273275

0 commit comments

Comments
 (0)