From: Mayank Haarit Date: Wed, 7 Dec 2016 15:17:16 +0000 (+0530) Subject: WFD: Clear wfd_subelems when P2P peer stops sending them X-Git-Tag: hostap_2_7~2049 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a431d49320ccebf9085d9c6d4940eb6f9135284;p=thirdparty%2Fhostap.git WFD: Clear wfd_subelems when P2P peer stops sending them When a peer device stops sending wfd_subelems, wpa_supplicant should remove dev->info.wfd_subelems from peer's properties. Previously, wpa_supplicant left the previously learned dev->info.wfd_subelems in place whenever the new message did not include wfd_subelems. In addition to fixing the clearing of the old wfd_subelems, this resolves another issue. As "wfd_changed" variable becomes true even when peer stops sending wfd_subelems and dev->info.wfd_subelems has an old value, a new P2P-DEVICE-FOUND event notification was sent again and again to upper layers whenever a new discovery response was received from the peer that previously advertised WFD subelements. Signed-off-by: Mayank Haarit --- diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 170e4778a..3e1e8961a 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -839,9 +839,12 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq, wfd_changed = p2p_compare_wfd_info(dev, &msg); - if (msg.wfd_subelems) { + if (wfd_changed) { wpabuf_free(dev->info.wfd_subelems); - dev->info.wfd_subelems = wpabuf_dup(msg.wfd_subelems); + if (msg.wfd_subelems) + dev->info.wfd_subelems = wpabuf_dup(msg.wfd_subelems); + else + dev->info.wfd_subelems = NULL; } if (scan_res) {