Skip to content

Commit 8eda10e

Browse files
Avinash Patillinvjw
authored andcommitted
mwifiex: ensure user_scan_in not NULL while setting scan channel gap
Check for scan channel gap only when user_scan_in is not NULL. user_scan_in is NULL for internal scans and if we check scan channel gap at this place, it may result into crash. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Avinash Patil <patila@marvell.com> Signed-off-by: Cathy Luo <cluo@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent cb35582 commit 8eda10e

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

  • drivers/net/wireless/mwifiex

‎drivers/net/wireless/mwifiex/scan.c‎

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,23 @@ mwifiex_config_scan(struct mwifiex_private *priv,
926926
if ((i && ssid_filter) ||
927927
!is_zero_ether_addr(scan_cfg_out->specific_bssid))
928928
*filtered_scan = true;
929+
930+
if (user_scan_in->scan_chan_gap) {
931+
dev_dbg(adapter->dev, "info: scan: channel gap = %d\n",
932+
user_scan_in->scan_chan_gap);
933+
*max_chan_per_scan =
934+
MWIFIEX_MAX_CHANNELS_PER_SPECIFIC_SCAN;
935+
936+
chan_gap_tlv = (void *)tlv_pos;
937+
chan_gap_tlv->header.type =
938+
cpu_to_le16(TLV_TYPE_SCAN_CHANNEL_GAP);
939+
chan_gap_tlv->header.len =
940+
cpu_to_le16(sizeof(chan_gap_tlv->chan_gap));
941+
chan_gap_tlv->chan_gap =
942+
cpu_to_le16((user_scan_in->scan_chan_gap));
943+
tlv_pos +=
944+
sizeof(struct mwifiex_ie_types_scan_chan_gap);
945+
}
929946
} else {
930947
scan_cfg_out->bss_mode = (u8) adapter->scan_mode;
931948
num_probes = adapter->scan_probes;
@@ -940,22 +957,6 @@ mwifiex_config_scan(struct mwifiex_private *priv,
940957
else
941958
*max_chan_per_scan = MWIFIEX_DEF_CHANNELS_PER_SCAN_CMD;
942959

943-
if (user_scan_in->scan_chan_gap) {
944-
*max_chan_per_scan = MWIFIEX_MAX_CHANNELS_PER_SPECIFIC_SCAN;
945-
dev_dbg(adapter->dev, "info: scan: channel gap = %d\n",
946-
user_scan_in->scan_chan_gap);
947-
948-
chan_gap_tlv = (void *)tlv_pos;
949-
chan_gap_tlv->header.type =
950-
cpu_to_le16(TLV_TYPE_SCAN_CHANNEL_GAP);
951-
chan_gap_tlv->header.len =
952-
cpu_to_le16(sizeof(chan_gap_tlv->chan_gap));
953-
chan_gap_tlv->chan_gap =
954-
cpu_to_le16((user_scan_in->scan_chan_gap));
955-
956-
tlv_pos += sizeof(struct mwifiex_ie_types_scan_chan_gap);
957-
}
958-
959960
/* If the input config or adapter has the number of Probes set,
960961
add tlv */
961962
if (num_probes) {

0 commit comments

Comments
 (0)