Browse Source

wpa_cli: Fix resource leak on attach failures in interactive mode

When starting interactive mode, wpa_cli is trying to attach the
monitor connection. If that fails, the operation is retried, but
this was done without freeing all the resources that could have
been allocated (mainly, the command connection).

Signed-hostap: Jouni Malinen <j@w1.fi>
Jouni Malinen 12 years ago
parent
commit
d62aaa7de1
1 changed files with 2 additions and 0 deletions
  1. 2 0
      wpa_supplicant/wpa_cli.c

+ 2 - 0
wpa_supplicant/wpa_cli.c

@@ -94,6 +94,7 @@ static DEFINE_DL_LIST(p2p_groups); /* struct cli_txt_entry */
 
 
 static void print_help(void);
 static void print_help(void);
 static void wpa_cli_mon_receive(int sock, void *eloop_ctx, void *sock_ctx);
 static void wpa_cli_mon_receive(int sock, void *eloop_ctx, void *sock_ctx);
+static void wpa_cli_close_connection(void);
 
 
 
 
 static void usage(void)
 static void usage(void)
@@ -361,6 +362,7 @@ static int wpa_cli_open_connection(const char *ifname, int attach)
 		} else {
 		} else {
 			printf("Warning: Failed to attach to "
 			printf("Warning: Failed to attach to "
 			       "wpa_supplicant.\n");
 			       "wpa_supplicant.\n");
+			wpa_cli_close_connection();
 			return -1;
 			return -1;
 		}
 		}
 	}
 	}