diff --git a/wpa_supplicant/offchannel.c b/wpa_supplicant/offchannel.c index 7ec7656d1..856eca708 100644 --- a/wpa_supplicant/offchannel.c +++ b/wpa_supplicant/offchannel.c @@ -356,6 +356,33 @@ void offchannel_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s, } +/** + * offchannel_pending_action_tx - Check whether there is a pending Action TX + * @wpa_s: Pointer to wpa_supplicant data + * Returns: Pointer to pending frame or %NULL if no pending operation + * + * This function can be used to check whether there is a pending Action frame TX + * operation. The returned pointer should be used only for checking whether it + * is %NULL (no pending frame) or to print the pointer value in debug + * information (i.e., the pointer should not be dereferenced). + */ +const void * offchannel_pending_action_tx(struct wpa_supplicant *wpa_s) +{ + return wpa_s->pending_action_tx; +} + + +/** + * offchannel_clear_pending_action_tx - Clear pending Action frame TX + * @wpa_s: Pointer to wpa_supplicant data + */ +void offchannel_clear_pending_action_tx(struct wpa_supplicant *wpa_s) +{ + wpabuf_free(wpa_s->pending_action_tx); + wpa_s->pending_action_tx = NULL; +} + + /** * offchannel_deinit - Deinit off-channel operations * @wpa_s: Pointer to wpa_supplicant data @@ -365,7 +392,6 @@ void offchannel_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s, */ void offchannel_deinit(struct wpa_supplicant *wpa_s) { - wpabuf_free(wpa_s->pending_action_tx); - wpa_s->pending_action_tx = NULL; + offchannel_clear_pending_action_tx(wpa_s); eloop_cancel_timeout(wpas_send_action_cb, wpa_s, NULL); } diff --git a/wpa_supplicant/offchannel.h b/wpa_supplicant/offchannel.h index 1d3948c0e..0ad7e18fa 100644 --- a/wpa_supplicant/offchannel.h +++ b/wpa_supplicant/offchannel.h @@ -29,5 +29,7 @@ void offchannel_deinit(struct wpa_supplicant *wpa_s); void offchannel_send_action_tx_status( struct wpa_supplicant *wpa_s, const u8 *dst, const u8 *data, size_t data_len, enum offchannel_send_action_result result); +const void * offchannel_pending_action_tx(struct wpa_supplicant *wpa_s); +void offchannel_clear_pending_action_tx(struct wpa_supplicant *wpa_s); #endif /* OFFCHANNEL_H */ diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index dc4d99a54..eefeac60c 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -3758,12 +3758,12 @@ void wpas_p2p_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s, { wpa_printf(MSG_DEBUG, "P2P: Cancel remain-on-channel callback " "(p2p_long_listen=%d ms pending_action_tx=%p)", - wpa_s->p2p_long_listen, wpa_s->pending_action_tx); + wpa_s->p2p_long_listen, offchannel_pending_action_tx(wpa_s)); if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) return; if (p2p_listen_end(wpa_s->global->p2p, freq) > 0) return; /* P2P module started a new operation */ - if (wpa_s->pending_action_tx) + if (offchannel_pending_action_tx(wpa_s)) return; if (wpa_s->p2p_long_listen > 0) wpa_s->p2p_long_listen -= wpa_s->max_remain_on_chan; @@ -4321,13 +4321,12 @@ int wpas_p2p_scan_result_text(const u8 *ies, size_t ies_len, char *buf, static void wpas_p2p_clear_pending_action_tx(struct wpa_supplicant *wpa_s) { - if (!wpa_s->pending_action_tx) + if (!offchannel_pending_action_tx(wpa_s)) return; wpa_printf(MSG_DEBUG, "P2P: Drop pending Action TX due to new " "operation request"); - wpabuf_free(wpa_s->pending_action_tx); - wpa_s->pending_action_tx = NULL; + offchannel_clear_pending_action_tx(wpa_s); }