mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 08:48:31 -05:00
P2P: Iterate through full pref_chan list in search of a valid channel
p2p_get_pref_freq() went through the full list only if the channels arguments was provided. If no channel list contraint was in place, the first pref_chan item was picked regardless of whether it is valid channel and as such, a later valid entry could have been ignored. Allow this to loop through all the entries until a valid channel is found or the end of the pref_chan list is reached. As an extra bonus, this simplifies the p2p_get_pref_freq() implementation quite a bit. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
parent
d00184df7c
commit
5cd0e228ac
@ -384,23 +384,14 @@ unsigned int p2p_get_pref_freq(struct p2p_data *p2p,
|
||||
const struct p2p_channels *channels)
|
||||
{
|
||||
unsigned int i;
|
||||
int freq = 0;
|
||||
|
||||
if (channels == NULL) {
|
||||
if (p2p->cfg->num_pref_chan) {
|
||||
freq = p2p_channel_to_freq(
|
||||
p2p->cfg->pref_chan[0].op_class,
|
||||
p2p->cfg->pref_chan[0].chan);
|
||||
if (freq < 0)
|
||||
freq = 0;
|
||||
}
|
||||
return freq;
|
||||
}
|
||||
int freq;
|
||||
|
||||
for (i = 0; p2p->cfg->pref_chan && i < p2p->cfg->num_pref_chan; i++) {
|
||||
freq = p2p_channel_to_freq(p2p->cfg->pref_chan[i].op_class,
|
||||
p2p->cfg->pref_chan[i].chan);
|
||||
if (p2p_channels_includes_freq(channels, freq))
|
||||
if (freq <= 0)
|
||||
continue;
|
||||
if (!channels || p2p_channels_includes_freq(channels, freq))
|
||||
return freq;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user