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 <mayank.h@samsung.com>
This commit is contained in:
Mayank Haarit 2016-12-07 20:47:16 +05:30 committed by Jouni Malinen
parent 0ef0921a1b
commit 9a431d4932

View file

@ -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) {