summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTianyu Li <tianyu.li@arm.com>2023-01-31 07:07:49 +0000
committerDamjan Marion <dmarion@0xa5.net>2023-03-07 11:35:26 +0000
commitb7936405abd2531ed32873c8705b6474fb3f43e2 (patch)
tree3c3f0aa3394aafc50a203c18adcd2989c99396cd
parent16581f5dcb069fc7094f615e4f25c4d8ca34c357 (diff)
avf: fix cli memory leak with incorrect options
Remove extra line_input and unformat_user. Type: fix Fixes: b4ff07a2f843 ("Intel Adaptive Virtual Function native device driver plugin") Signed-off-by: Tianyu Li <tianyu.li@arm.com> Change-Id: I9e502f3b254d0b1c7d8fd4b80925338a18da8269
-rw-r--r--src/plugins/avf/cli.c56
1 files changed, 19 insertions, 37 deletions
diff --git a/src/plugins/avf/cli.c b/src/plugins/avf/cli.c
index 47b4b9236f2..54d167d2b03 100644
--- a/src/plugins/avf/cli.c
+++ b/src/plugins/avf/cli.c
@@ -30,37 +30,31 @@ static clib_error_t *
avf_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
- unformat_input_t _line_input, *line_input = &_line_input;
avf_create_if_args_t args;
u32 tmp;
clib_memset (&args, 0, sizeof (avf_create_if_args_t));
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (line_input, "%U", unformat_vlib_pci_addr, &args.addr))
+ if (unformat (input, "%U", unformat_vlib_pci_addr, &args.addr))
;
- else if (unformat (line_input, "elog"))
+ else if (unformat (input, "elog"))
args.enable_elog = 1;
- else if (unformat (line_input, "rx-queue-size %u", &tmp))
+ else if (unformat (input, "rx-queue-size %u", &tmp))
args.rxq_size = tmp;
- else if (unformat (line_input, "tx-queue-size %u", &tmp))
+ else if (unformat (input, "tx-queue-size %u", &tmp))
args.txq_size = tmp;
- else if (unformat (line_input, "num-rx-queues %u", &tmp))
+ else if (unformat (input, "num-rx-queues %u", &tmp))
args.rxq_num = tmp;
- else if (unformat (line_input, "num-tx-queues %u", &tmp))
+ else if (unformat (input, "num-tx-queues %u", &tmp))
args.txq_num = tmp;
- else if (unformat (line_input, "name %s", &args.name))
+ else if (unformat (input, "name %s", &args.name))
;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
}
- unformat_free (line_input);
avf_create_if (vm, &args);
@@ -83,27 +77,21 @@ static clib_error_t *
avf_delete_command_fn (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
- unformat_input_t _line_input, *line_input = &_line_input;
u32 sw_if_index = ~0;
vnet_hw_interface_t *hw;
vnet_main_t *vnm = vnet_get_main ();
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (line_input, "sw_if_index %d", &sw_if_index))
+ if (unformat (input, "sw_if_index %d", &sw_if_index))
;
- else if (unformat (line_input, "%U", unformat_vnet_sw_interface,
- vnm, &sw_if_index))
+ else if (unformat (input, "%U", unformat_vnet_sw_interface, vnm,
+ &sw_if_index))
;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
}
- unformat_free (line_input);
if (sw_if_index == ~0)
return clib_error_return (0,
@@ -133,35 +121,29 @@ static clib_error_t *
avf_test_command_fn (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
- unformat_input_t _line_input, *line_input = &_line_input;
u32 sw_if_index = ~0;
vnet_hw_interface_t *hw;
avf_device_t *ad;
vnet_main_t *vnm = vnet_get_main ();
int test_irq = 0, enable_elog = 0, disable_elog = 0;
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (line_input, "sw_if_index %d", &sw_if_index))
+ if (unformat (input, "sw_if_index %d", &sw_if_index))
;
- else if (unformat (line_input, "irq"))
+ else if (unformat (input, "irq"))
test_irq = 1;
- else if (unformat (line_input, "elog-on"))
+ else if (unformat (input, "elog-on"))
enable_elog = 1;
- else if (unformat (line_input, "elog-off"))
+ else if (unformat (input, "elog-off"))
disable_elog = 1;
- else if (unformat (line_input, "%U", unformat_vnet_sw_interface,
- vnm, &sw_if_index))
+ else if (unformat (input, "%U", unformat_vnet_sw_interface, vnm,
+ &sw_if_index))
;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
}
- unformat_free (line_input);
if (sw_if_index == ~0)
return clib_error_return (0,