diff options
author | Steven Luong <sluong@cisco.com> | 2024-08-06 13:28:09 -0700 |
---|---|---|
committer | Steven Luong <sluong@cisco.com> | 2024-08-06 13:30:31 -0700 |
commit | 0a3b0b231d8d2978c3322cc5ba8e1d2746a6d730 (patch) | |
tree | ebf2cb3b6cc6d66be8e7ff565d9dcad98c4b32a4 | |
parent | d46e674abc5605b58584bbf9a0607ef621ca0eee (diff) |
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>
-rw-r--r-- | src/vnet/session/session_lookup.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/vnet/session/session_lookup.c b/src/vnet/session/session_lookup.c index 3a461a5949f..217fe9ad209 100644 --- a/src/vnet/session/session_lookup.c +++ b/src/vnet/session/session_lookup.c @@ -1707,14 +1707,17 @@ show_session_rules_command_fn (vlib_main_t * vm, unformat_input_t * input, 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 @@ show_session_rules_command_fn (vlib_main_t * vm, unformat_input_t * input, if (!app_ns) { vlib_cli_output (vm, "appns %v doesn't exist", ns_id); - return 0; + goto done; } } else @@ -1747,7 +1750,7 @@ show_session_rules_command_fn (vlib_main_t * vm, unformat_input_t * input, 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 @@ show_session_rules_command_fn (vlib_main_t * vm, unformat_input_t * input, session_rules_table_cli_dump (vm, srt, FIB_PROTOCOL_IP6); } } - +done: vec_free (ns_id); return 0; } |