diff mbox

This patch is to clear existing dev->info.wfd_subelems when peer stops sending wfd_subelems.

Message ID 1481123836-6101-1-git-send-email-mayank.h@samsung.com
State Accepted
Headers show

Commit Message

MAYANK HAARIT Dec. 7, 2016, 3:17 p.m. UTC
This patch fixes below scenario:

When peer device stops sending wfd_subelems , then supplicant should remove dev->info.wfd_subelems from device's property.
Currently , Supplicant is not removing old dev->info.wfd_subelems.

Also , Above behaviour generates another issue :

As "wfd_changed" variable becomes true even when peer stops sending wfd_subelems and dev->info.wfd_subelems has an old value.
It results in notifying P2P-DEVICE-FOUND event again and again to upper layer.

Signed-off-by: Mayank Haarit <mayank.h@samsung.com>
---
 src/p2p/p2p.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Jouni Malinen Dec. 11, 2016, 11:02 p.m. UTC | #1
On Wed, Dec 07, 2016 at 08:47:16PM +0530, Mayank Haarit wrote:
> This patch fixes below scenario:
> 
> When peer device stops sending wfd_subelems , then supplicant should remove dev->info.wfd_subelems from device's property.
> Currently , Supplicant is not removing old dev->info.wfd_subelems.
> 
> Also , Above behaviour generates another issue :
> 
> As "wfd_changed" variable becomes true even when peer stops sending wfd_subelems and dev->info.wfd_subelems has an old value.
> It results in notifying P2P-DEVICE-FOUND event again and again to upper layer.

Thanks, applied.
diff mbox

Patch

diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index cd2fba3..8cc1971 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);
+		dev->info.wfd_subelems = NULL;
+		if (msg.wfd_subelems)
+			dev->info.wfd_subelems = wpabuf_dup(msg.wfd_subelems);
 	}
 
 	if (scan_res) {