Accumulative patch from commit 17b8995cf5813d7c027cd7a6884700e791d72392

17b8995 Interworking: Try to use same BSS entry for storing GAS results
3db5439 Optimize Extended Capabilities element to be of minimal length
8cd6b7b hostapd/wpa_s: Use driver's extended capabilities
acb5464 Add ctrl_iface command FLUSH for clearing wpa_supplicant state
97236ce WPS: Skip rescanning after provisioning if AP was configured
4342326 Add ignore_old_scan_res configuration parameter
9599ccc WPS: Clear after_wps on new WPS connection
702621e WPS: Use latest updated BSS entry if multiple BSSID matches found
ab547b5 WPS: Add more helpful debug for invalid WPS_REG command parsing
a679c0f WPS: Allow hostapd process to control independent WPS interfaces
ccdff94 WPS AP: Add support for reconfiguration with in-memory config
8970bae nl80211: Use nla_nest_start/end instead of nla_put_nested
558d69e P2P: Omit P2P Group Info in case of no connected peers
65a32cd AP: Fix infinite loop in WPA state machine when out of random bytes
a5f61b2 Fix OLBC non-HT AP detection to check channel
69554d7 ap_list: Remove unused functions
08c99ca ap_list: Remove unused iteration list pointers
6b16917 ap_list: Remove unused fields
66f1f75 P2P: Fix provision discovery response handling in some cases
2f9b66d Extend ROAM command to handle multiple SSIDs per BSS

Change-Id: I46002b1d3bbf6e376c2ae09bcb2c824c54805bbd
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/src/p2p/p2p_group.c b/src/p2p/p2p_group.c
index edb8d72..852ddf5 100644
--- a/src/p2p/p2p_group.c
+++ b/src/p2p/p2p_group.c
@@ -399,7 +399,6 @@
 
 static struct wpabuf * p2p_group_build_probe_resp_ie(struct p2p_group *group)
 {
-	u8 *group_info;
 	struct wpabuf *p2p_subelems, *ie;
 	struct p2p_group_member *m;
 
@@ -413,14 +412,18 @@
 	/* P2P Device Info */
 	p2p_buf_add_device_info(p2p_subelems, group->p2p, NULL);
 
-	/* P2P Group Info */
-	group_info = wpabuf_put(p2p_subelems, 0);
-	wpabuf_put_u8(p2p_subelems, P2P_ATTR_GROUP_INFO);
-	wpabuf_put_le16(p2p_subelems, 0); /* Length to be filled */
-	for (m = group->members; m; m = m->next)
-		p2p_client_info(p2p_subelems, m);
-	WPA_PUT_LE16(group_info + 1,
-		     (u8 *) wpabuf_put(p2p_subelems, 0) - group_info - 3);
+	/* P2P Group Info: Only when at least one P2P Client is connected */
+	if (group->members) {
+		u8 *group_info;
+		group_info = wpabuf_put(p2p_subelems, 0);
+		wpabuf_put_u8(p2p_subelems, P2P_ATTR_GROUP_INFO);
+		wpabuf_put_le16(p2p_subelems, 0); /* Length to be filled */
+		for (m = group->members; m; m = m->next)
+			p2p_client_info(p2p_subelems, m);
+		WPA_PUT_LE16(group_info + 1,
+			     (u8 *) wpabuf_put(p2p_subelems, 0) - group_info -
+			     3);
+	}
 
 	ie = p2p_group_encaps_probe_resp(p2p_subelems);
 	wpabuf_free(p2p_subelems);