P2P: Fix the calculation of group common freqs
authorIlan Peer <ilan.peer@intel.com>
Tue, 8 Sep 2015 09:46:09 +0000 (12:46 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 25 Sep 2015 18:05:42 +0000 (21:05 +0300)
Previously, the calculation allowed for the same frequency to appear
several times in the result.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
src/p2p/p2p_utils.c

index e139d03..2e2aa8a 100644 (file)
@@ -459,12 +459,22 @@ int p2p_channels_to_freqs(const struct p2p_channels *channels, int *freq_list,
                        break;
                for (j = 0; j < c->channels; j++) {
                        int freq;
+                       unsigned int k;
+
                        if (idx + 1 == max_len)
                                break;
                        freq = p2p_channel_to_freq(c->reg_class,
                                                   c->channel[j]);
                        if (freq < 0)
                                continue;
+
+                       for (k = 0; k < idx; k++) {
+                               if (freq_list[k] == freq)
+                                       break;
+                       }
+
+                       if (k < idx)
+                               continue;
                        freq_list[idx++] = freq;
                }
        }