[PATCH] Fix-up stale pointer after reconnect
Matthew Cather
mattbob4 at gmail.com
Wed Oct 8 13:20:35 PDT 2025
While investigating an issue with hostapd, I seem to have stumbled
onto a bug in `hostapd_cli`. The patch below is a sugested fix but
there may be a better approach.
If our `PING` fails and we close the connection then our `ctrl`
pointer becomes invalid. After reconnect we should replace `ctrl`
with a valid pointer.
Signed-off-by: Matthew Cather <mattbob4 at gmail.com>
---
hostapd/hostapd_cli.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c
index 95f7fd2d8..5efeceaf0 100644
--- a/hostapd/hostapd_cli.c
+++ b/hostapd/hostapd_cli.c
@@ -2189,9 +2189,11 @@ static void hostapd_cli_action_ping(void *eloop_ctx, void *timeout_ctx)
eloop_terminate();
return;
}
+ eloop_cancel_timeout(hostapd_cli_action_ping, ctrl, timeout_ctx);
+ ctrl = ctrl_conn;
}
eloop_register_timeout(ping_interval, 0, hostapd_cli_action_ping,
- ctrl, NULL);
+ ctrl, timeout_ctx);
}
@@ -2210,10 +2212,10 @@ static void hostapd_cli_action(struct wpa_ctrl *ctrl)
fd = wpa_ctrl_get_fd(ctrl);
eloop_register_timeout(ping_interval, 0, hostapd_cli_action_ping,
- ctrl, NULL);
+ ctrl, ctrl);
eloop_register_read_sock(fd, hostapd_cli_action_receive, ctrl, NULL);
eloop_run();
- eloop_cancel_timeout(hostapd_cli_action_ping, ctrl, NULL);
+ eloop_cancel_timeout(hostapd_cli_action_ping, ELOOP_ALL_CTX, ctrl);
eloop_unregister_read_sock(fd);
}
--
2.43.0
More information about the Hostap
mailing list