提交 571d6eee 编写于 作者: A Arnaldo Carvalho de Melo 提交者: Jeff Garzik

[PATCH] Check ieee80211softmac_auth_resp kmalloc result

And use kmemdup and kzalloc where applicable
Signed-off-by: NArnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 8e87295b
...@@ -67,7 +67,7 @@ static int ieee80211_networks_allocate(struct ieee80211_device *ieee) ...@@ -67,7 +67,7 @@ static int ieee80211_networks_allocate(struct ieee80211_device *ieee)
return 0; return 0;
ieee->networks = ieee->networks =
kmalloc(MAX_NETWORK_COUNT * sizeof(struct ieee80211_network), kzalloc(MAX_NETWORK_COUNT * sizeof(struct ieee80211_network),
GFP_KERNEL); GFP_KERNEL);
if (!ieee->networks) { if (!ieee->networks) {
printk(KERN_WARNING "%s: Out of memory allocating beacons\n", printk(KERN_WARNING "%s: Out of memory allocating beacons\n",
...@@ -75,9 +75,6 @@ static int ieee80211_networks_allocate(struct ieee80211_device *ieee) ...@@ -75,9 +75,6 @@ static int ieee80211_networks_allocate(struct ieee80211_device *ieee)
return -ENOMEM; return -ENOMEM;
} }
memset(ieee->networks, 0,
MAX_NETWORK_COUNT * sizeof(struct ieee80211_network));
return 0; return 0;
} }
......
...@@ -1304,12 +1304,11 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element ...@@ -1304,12 +1304,11 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element
case MFIE_TYPE_IBSS_DFS: case MFIE_TYPE_IBSS_DFS:
if (network->ibss_dfs) if (network->ibss_dfs)
break; break;
network->ibss_dfs = network->ibss_dfs = kmemdup(info_element->data,
kmalloc(info_element->len, GFP_ATOMIC); info_element->len,
GFP_ATOMIC);
if (!network->ibss_dfs) if (!network->ibss_dfs)
return 1; return 1;
memcpy(network->ibss_dfs, info_element->data,
info_element->len);
network->flags |= NETWORK_HAS_IBSS_DFS; network->flags |= NETWORK_HAS_IBSS_DFS;
break; break;
......
...@@ -216,10 +216,16 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth) ...@@ -216,10 +216,16 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
net->challenge_len = *data++; net->challenge_len = *data++;
if (net->challenge_len > WLAN_AUTH_CHALLENGE_LEN) if (net->challenge_len > WLAN_AUTH_CHALLENGE_LEN)
net->challenge_len = WLAN_AUTH_CHALLENGE_LEN; net->challenge_len = WLAN_AUTH_CHALLENGE_LEN;
if (net->challenge != NULL) kfree(net->challenge);
kfree(net->challenge); net->challenge = kmemdup(data, net->challenge_len,
net->challenge = kmalloc(net->challenge_len, GFP_ATOMIC); GFP_ATOMIC);
memcpy(net->challenge, data, net->challenge_len); if (net->challenge == NULL) {
printkl(KERN_NOTICE PFX "Shared Key "
"Authentication failed due to "
"memory shortage.\n");
spin_unlock_irqrestore(&mac->lock, flags);
break;
}
aq->state = IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE; aq->state = IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE;
/* We reuse the work struct from the auth request here. /* We reuse the work struct from the auth request here.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册