linux-cp: fix lcp_itf_pair_create()'s memory leak 62/37562/2
authorluoyaozu <[email protected]>
Mon, 31 Oct 2022 13:46:38 +0000 (21:46 +0800)
committerMatthew Smith <[email protected]>
Thu, 10 Nov 2022 18:48:09 +0000 (18:48 +0000)
need free args.error if args.rv < 0

Type: fix

Signed-off-by: luoyaozu <[email protected]>
Change-Id: I8ceebfc36f51798d8d1a8e4c41bec33d74344396

src/plugins/linux-cp/lcp_interface.c

index d629a06..eef06ec 100644 (file)
@@ -979,6 +979,8 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
        .tx_ring_sz = 256,
        .host_if_name = host_if_name,
        .host_namespace = 0,
+       .rv = 0,
+       .error = NULL,
       };
       ethernet_interface_t *ei;
       u32 host_sw_mtu_size;
@@ -1017,6 +1019,7 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
        {
          LCP_ITF_PAIR_ERR ("pair_create: could not create tap, retval:%d",
                            args.rv);
+         clib_error_free (args.error);
          return args.rv;
        }