From: Matthew Smith Date: Tue, 16 Feb 2021 16:02:46 +0000 (-0600) Subject: linux-cp: fix coverity defect X-Git-Tag: v21.10-rc0~513 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=6abdf34d3a4e47fb9bb5d8052e2187af0ba256d8;p=vpp.git linux-cp: fix coverity defect Type: fix If no host interface name is passed to the CLI command which creates an interface pair, NULL gets passed to lcp_itf_pair_create() and a seg fault occurs. Check whether a host interface name was provided and fail gracefully if none was given. Change-Id: I82886f4c2ee710e206c751c34a74399112e9062c Signed-off-by: Matthew Smith --- diff --git a/src/plugins/linux-cp/lcp_cli.c b/src/plugins/linux-cp/lcp_cli.c index 3b0598c1b66..0231f67f835 100644 --- a/src/plugins/linux-cp/lcp_cli.c +++ b/src/plugins/linux-cp/lcp_cli.c @@ -72,6 +72,12 @@ lcp_itf_pair_create_command_fn (vlib_main_t *vm, unformat_input_t *input, unformat_free (line_input); + if (!host_if_name) + { + vec_free (ns); + return clib_error_return (0, "host interface name required"); + } + if (sw_if_index == ~0) { vec_free (host_if_name);