diff options
| author | Rami Rosen <ramirose@gmail.com> | 2008-10-22 03:58:39 -0400 |
|---|---|---|
| committer | John W. Linville <linville@tuxdriver.com> | 2008-10-31 19:00:51 -0400 |
| commit | e2ef12d3fdb771002e7c7b6bd8f19902b1934e03 (patch) | |
| tree | 5699a939cc61cc6c140f3b822e285e6e9f661cc1 | |
| parent | 72118015271e6d3852cb9f647efe0987d131adaa (diff) | |
mac80211: check return value of dev_alloc_skb() in ieee80211_sta_join_ibss().
This patch add a check on the return value of dev_alloc_skb() in
ieee80211_sta_join_ibss() in net/mac80211/mlme.c.
Signed-off-by: Rami Rosen <ramirose@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
| -rw-r--r-- | net/mac80211/mlme.c | 104 |
1 files changed, 55 insertions, 49 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 026f07a173b6..29fafbe440b7 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
| @@ -1379,6 +1379,13 @@ static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
| 1379 | struct ieee80211_supported_band *sband; | 1379 | struct ieee80211_supported_band *sband; |
| 1380 | union iwreq_data wrqu; | 1380 | union iwreq_data wrqu; |
| 1381 | 1381 | ||
| 1382 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); | ||
| 1383 | if (!skb) { | ||
| 1384 | printk(KERN_DEBUG "%s: failed to allocate buffer for probe " | ||
| 1385 | "response\n", sdata->dev->name); | ||
| 1386 | return -ENOMEM; | ||
| 1387 | } | ||
| 1388 | |||
| 1382 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | 1389 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
| 1383 | 1390 | ||
| 1384 | /* Remove possible STA entries from other IBSS networks. */ | 1391 | /* Remove possible STA entries from other IBSS networks. */ |
| @@ -1404,63 +1411,62 @@ static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
| 1404 | return res; | 1411 | return res; |
| 1405 | 1412 | ||
| 1406 | /* Build IBSS probe response */ | 1413 | /* Build IBSS probe response */ |
| 1407 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); | ||
| 1408 | if (skb) { | ||
| 1409 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
| 1410 | 1414 | ||
| 1411 | mgmt = (struct ieee80211_mgmt *) | 1415 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 1412 | skb_put(skb, 24 + sizeof(mgmt->u.beacon)); | ||
| 1413 | memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); | ||
| 1414 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | ||
| 1415 | IEEE80211_STYPE_PROBE_RESP); | ||
| 1416 | memset(mgmt->da, 0xff, ETH_ALEN); | ||
| 1417 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | ||
| 1418 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); | ||
| 1419 | mgmt->u.beacon.beacon_int = | ||
| 1420 | cpu_to_le16(local->hw.conf.beacon_int); | ||
| 1421 | mgmt->u.beacon.timestamp = cpu_to_le64(bss->timestamp); | ||
| 1422 | mgmt->u.beacon.capab_info = cpu_to_le16(bss->capability); | ||
| 1423 | |||
| 1424 | pos = skb_put(skb, 2 + ifsta->ssid_len); | ||
| 1425 | *pos++ = WLAN_EID_SSID; | ||
| 1426 | *pos++ = ifsta->ssid_len; | ||
| 1427 | memcpy(pos, ifsta->ssid, ifsta->ssid_len); | ||
| 1428 | |||
| 1429 | rates = bss->supp_rates_len; | ||
| 1430 | if (rates > 8) | ||
| 1431 | rates = 8; | ||
| 1432 | pos = skb_put(skb, 2 + rates); | ||
| 1433 | *pos++ = WLAN_EID_SUPP_RATES; | ||
| 1434 | *pos++ = rates; | ||
| 1435 | memcpy(pos, bss->supp_rates, rates); | ||
| 1436 | 1416 | ||
| 1437 | if (bss->band == IEEE80211_BAND_2GHZ) { | 1417 | mgmt = (struct ieee80211_mgmt *) |
| 1438 | pos = skb_put(skb, 2 + 1); | 1418 | skb_put(skb, 24 + sizeof(mgmt->u.beacon)); |
| 1439 | *pos++ = WLAN_EID_DS_PARAMS; | 1419 | memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); |
| 1440 | *pos++ = 1; | 1420 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 1441 | *pos++ = ieee80211_frequency_to_channel(bss->freq); | 1421 | IEEE80211_STYPE_PROBE_RESP); |
| 1442 | } | 1422 | memset(mgmt->da, 0xff, ETH_ALEN); |
| 1423 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | ||
| 1424 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); | ||
| 1425 | mgmt->u.beacon.beacon_int = | ||
| 1426 | cpu_to_le16(local->hw.conf.beacon_int); | ||
| 1427 | mgmt->u.beacon.timestamp = cpu_to_le64(bss->timestamp); | ||
| 1428 | mgmt->u.beacon.capab_info = cpu_to_le16(bss->capability); | ||
| 1443 | 1429 | ||
| 1444 | pos = skb_put(skb, 2 + 2); | 1430 | pos = skb_put(skb, 2 + ifsta->ssid_len); |
| 1445 | *pos++ = WLAN_EID_IBSS_PARAMS; | 1431 | *pos++ = WLAN_EID_SSID; |
| 1446 | *pos++ = 2; | 1432 | *pos++ = ifsta->ssid_len; |
| 1447 | /* FIX: set ATIM window based on scan results */ | 1433 | memcpy(pos, ifsta->ssid, ifsta->ssid_len); |
| 1448 | *pos++ = 0; | ||
| 1449 | *pos++ = 0; | ||
| 1450 | 1434 | ||
| 1451 | if (bss->supp_rates_len > 8) { | 1435 | rates = bss->supp_rates_len; |
| 1452 | rates = bss->supp_rates_len - 8; | 1436 | if (rates > 8) |
| 1453 | pos = skb_put(skb, 2 + rates); | 1437 | rates = 8; |
| 1454 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | 1438 | pos = skb_put(skb, 2 + rates); |
| 1455 | *pos++ = rates; | 1439 | *pos++ = WLAN_EID_SUPP_RATES; |
| 1456 | memcpy(pos, &bss->supp_rates[8], rates); | 1440 | *pos++ = rates; |
| 1457 | } | 1441 | memcpy(pos, bss->supp_rates, rates); |
| 1458 | 1442 | ||
| 1459 | ifsta->probe_resp = skb; | 1443 | if (bss->band == IEEE80211_BAND_2GHZ) { |
| 1444 | pos = skb_put(skb, 2 + 1); | ||
| 1445 | *pos++ = WLAN_EID_DS_PARAMS; | ||
| 1446 | *pos++ = 1; | ||
| 1447 | *pos++ = ieee80211_frequency_to_channel(bss->freq); | ||
| 1448 | } | ||
| 1449 | |||
| 1450 | pos = skb_put(skb, 2 + 2); | ||
| 1451 | *pos++ = WLAN_EID_IBSS_PARAMS; | ||
| 1452 | *pos++ = 2; | ||
| 1453 | /* FIX: set ATIM window based on scan results */ | ||
| 1454 | *pos++ = 0; | ||
| 1455 | *pos++ = 0; | ||
| 1460 | 1456 | ||
| 1461 | ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON); | 1457 | if (bss->supp_rates_len > 8) { |
| 1458 | rates = bss->supp_rates_len - 8; | ||
| 1459 | pos = skb_put(skb, 2 + rates); | ||
| 1460 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | ||
| 1461 | *pos++ = rates; | ||
| 1462 | memcpy(pos, &bss->supp_rates[8], rates); | ||
| 1462 | } | 1463 | } |
| 1463 | 1464 | ||
| 1465 | ifsta->probe_resp = skb; | ||
| 1466 | |||
| 1467 | ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON); | ||
| 1468 | |||
| 1469 | |||
| 1464 | rates = 0; | 1470 | rates = 0; |
| 1465 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | 1471 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
| 1466 | for (i = 0; i < bss->supp_rates_len; i++) { | 1472 | for (i = 0; i < bss->supp_rates_len; i++) { |
