Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
[nrf noup] zephyr: Don't use heap for WPA cli
Browse files Browse the repository at this point in the history
Relying on heap during OOM is bad, esp. for critical module like WPA
supplicant, this can break the Wi-Fi.

As the WPA supplicant stack is large enough and this buffer is free
immediately after use, just use the stack.

Fixes SHEL-2283.

Signed-off-by: Chaitanya Tata <[email protected]>
  • Loading branch information
krish2718 committed Feb 8, 2024
1 parent ecebc52 commit 37c83a4
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions wpa_supplicant/wpa_cli_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static DEFINE_DL_LIST(stations); /* struct cli_txt_entry */
static int wpa_cli_cmd(struct wpa_ctrl *ctrl, const char *cmd, int min_args,
int argc, char *argv[])
{
char * buf = NULL;
char buf[CMD_BUF_LEN] = {0};
int ret = 0;
bool interactive = 0;

Expand All @@ -58,13 +58,7 @@ static int wpa_cli_cmd(struct wpa_ctrl *ctrl, const char *cmd, int min_args,
min_args > 1 ? "s are" : " is");
return -1;
}
buf = os_zalloc(sizeof(char) * CMD_BUF_LEN);
if (!buf){
wpa_printf(MSG_ERROR, "Failed to allocate mem for command buf - %d\n",
CMD_BUF_LEN);
return -1;
}
memset(buf, '\0', CMD_BUF_LEN);

if (write_cmd(buf, CMD_BUF_LEN, cmd, argc, argv) < 0){
ret = -1;
goto out;
Expand All @@ -76,9 +70,6 @@ static int wpa_cli_cmd(struct wpa_ctrl *ctrl, const char *cmd, int min_args,
ret = wpa_ctrl_command(ctrl, buf);

out:
if (buf)
os_free(buf);

return ret;
}

Expand Down

0 comments on commit 37c83a4

Please sign in to comment.