session: memory leak in show session rules
Need to vec_free ns_id whenever we return in the function
show_session_rules_command_fn in case memory was allocated to it.
Type: fix
Change-Id: Ifc38d3eb2756a8a128467dd40ad40fe3f0be8fc0
Signed-off-by: Steven Luong <sluong@cisco.com>
diff --git a/src/vnet/session/session_lookup.c b/src/vnet/session/session_lookup.c
index 3a461a5..217fe9a 100644
--- a/src/vnet/session/session_lookup.c
+++ b/src/vnet/session/session_lookup.c
@@ -1707,14 +1707,17 @@
show_one = 1;
}
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ vec_free (ns_id);
+ return clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, input);
+ }
}
if (transport_proto == ~0)
{
vlib_cli_output (vm, "transport proto must be set");
- return 0;
+ goto done;
}
if (ns_id)
@@ -1723,7 +1726,7 @@
if (!app_ns)
{
vlib_cli_output (vm, "appns %v doesn't exist", ns_id);
- return 0;
+ goto done;
}
}
else
@@ -1747,7 +1750,7 @@
srt = &st->session_rules[transport_proto];
session_rules_table_show_rule (vm, srt, &lcl_ip, lcl_port, &rmt_ip,
rmt_port, is_ip4);
- return 0;
+ goto done;
}
vlib_cli_output (vm, "%U rules table", format_transport_proto,
@@ -1782,7 +1785,7 @@
session_rules_table_cli_dump (vm, srt, FIB_PROTOCOL_IP6);
}
}
-
+done:
vec_free (ns_id);
return 0;
}