From: Dan Callaghan Date: Mon, 10 Nov 2025 03:08:02 +0000 (+1100) Subject: P2P: Add missing NULL check in p2p_ctrl_flush() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ec82ea85a5d4a2f8e81fe81fdbfc9d0617a74e4;p=thirdparty%2Fhostap.git P2P: Add missing NULL check in p2p_ctrl_flush() When wpa_supplicant is compiled with CONFIG_TESTING_OPTIONS and receives a FLUSH command from wpa_cli, p2p_ctrl_flush() may crash due to passing a NULL pointer into p2p_set_invitation_op_freq(). Add a NULL pointer check, similar to the other NULL pointer check already in p2p_ctrl_flush(). Fixes: 475f50d71001 ("P2P2: Allow op class and channel override for Invitation Response") Signed-off-by: Dan Callaghan --- diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 4426d45f6..92ab86fc0 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -7922,7 +7922,8 @@ static void p2p_ctrl_flush(struct wpa_supplicant *wpa_s) #ifdef CONFIG_TESTING_OPTIONS os_free(wpa_s->get_pref_freq_list_override); wpa_s->get_pref_freq_list_override = NULL; - p2p_set_invitation_op_freq(wpa_s->global->p2p, -1); + if (wpa_s->global->p2p) + p2p_set_invitation_op_freq(wpa_s->global->p2p, -1); #endif /* CONFIG_TESTING_OPTIONS */ wpas_p2p_stop_find(wpa_s);