call unformat_free in some flow, remove unnecessary calls

Change-Id: I565277eafbce3d4f59a7f0d497fca1c4fed3cfc8
Signed-off-by: Swarup Nayak <swarupnpvt@gmail.com>
diff --git a/src/plugins/nat/nat.c b/src/plugins/nat/nat.c
index 896fe5f..3c891f2 100644
--- a/src/plugins/nat/nat.c
+++ b/src/plugins/nat/nat.c
@@ -3461,8 +3461,6 @@
         }
     }
 
-  unformat_free (line_input);
-
   rv = snat_det_add_map(sm, &in_addr, (u8) in_plen, &out_addr, (u8)out_plen,
                         is_add);
 
@@ -3523,8 +3521,6 @@
         }
     }
 
-  unformat_free (line_input);
-
   dm = snat_det_map_by_user(sm, &in_addr);
   if (!dm)
     vlib_cli_output (vm, "no match");
@@ -3584,8 +3580,6 @@
         }
     }
 
-  unformat_free (line_input);
-
   if (out_port < 1024 || out_port > 65535)
     {
       error = clib_error_return (0, "wrong port, must be <1024-65535>");
@@ -3662,8 +3656,6 @@
         }
     }
 
-  unformat_free (line_input);
-
 done:
   unformat_free (line_input);
 
diff --git a/src/vnet/devices/tap/cli.c b/src/vnet/devices/tap/cli.c
index c86995c..7dd525b 100644
--- a/src/vnet/devices/tap/cli.c
+++ b/src/vnet/devices/tap/cli.c
@@ -43,7 +43,6 @@
   /* Get a line of input. */
   if (unformat_user (input, unformat_line_input, line_input))
     {
-
       while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
 	{
 	  if (unformat (line_input, "id %u", &args.id))
@@ -74,8 +73,11 @@
 			     unformat_ethernet_address, args.mac_addr))
 	    args.mac_addr_set = 1;
 	  else
-	    return clib_error_return (0, "unknown input `%U'",
-				      format_unformat_error, input);
+	    {
+	      unformat_free (line_input);
+	      return clib_error_return (0, "unknown input `%U'",
+					format_unformat_error, input);
+	    }
 	}
       unformat_free (line_input);
     }
diff --git a/src/vnet/ip/lookup.c b/src/vnet/ip/lookup.c
index 95039bd..67e46bd 100644
--- a/src/vnet/ip/lookup.c
+++ b/src/vnet/ip/lookup.c
@@ -1398,12 +1398,16 @@
       else if (unformat (line_input, "del"))
 	is_del = 1;
       else
-	return (clib_error_return (0, "unknown input '%U'",
-				   format_unformat_error, line_input));
+	{
+	  unformat_free (line_input);
+	  return (clib_error_return (0, "unknown input '%U'",
+				     format_unformat_error, line_input));
+	}
     }
 
   if (~0 == sw_if_index || !addr_set)
     {
+      unformat_free (line_input);
       vlib_cli_output (vm, "interface and address must be set");
       return 0;
     }
@@ -1456,12 +1460,16 @@
 			 unformat_vnet_sw_interface, vnm, &sw_if_index))
 	;
       else
-	return (clib_error_return (0, "unknown input '%U'",
-				   format_unformat_error, line_input));
+	{
+	  unformat_free (line_input);
+	  return (clib_error_return (0, "unknown input '%U'",
+				     format_unformat_error, line_input));
+	}
     }
 
   if (~0 == sw_if_index)
     {
+      unformat_free (line_input);
       vlib_cli_output (vm, "no interface");
       return (clib_error_return (0, "no interface"));
     }