diff options
author | Arnaldo Carvalho de Melo <acme@mandriva.com> | 2006-11-20 22:26:49 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-12-02 00:12:05 -0500 |
commit | 571d6eee9b5bce28fcbeb7588890ad5ca3f8c718 (patch) | |
tree | 38ad5d544dc9c14fc49a03957c24ee7a2e450b60 /net/ieee80211 | |
parent | 8e87295b9578fa46b5f325a7dc42ddbbdad6e0d0 (diff) |
[PATCH] Check ieee80211softmac_auth_resp kmalloc result
And use kmemdup and kzalloc where applicable
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/ieee80211')
-rw-r--r-- | net/ieee80211/ieee80211_module.c | 5 | ||||
-rw-r--r-- | net/ieee80211/ieee80211_rx.c | 7 | ||||
-rw-r--r-- | net/ieee80211/softmac/ieee80211softmac_auth.c | 14 |
3 files changed, 14 insertions, 12 deletions
diff --git a/net/ieee80211/ieee80211_module.c b/net/ieee80211/ieee80211_module.c index 2b14c2f3e21d..f16e60ee9ce9 100644 --- a/net/ieee80211/ieee80211_module.c +++ b/net/ieee80211/ieee80211_module.c | |||
@@ -67,7 +67,7 @@ static int ieee80211_networks_allocate(struct ieee80211_device *ieee) | |||
67 | return 0; | 67 | return 0; |
68 | 68 | ||
69 | ieee->networks = | 69 | ieee->networks = |
70 | kmalloc(MAX_NETWORK_COUNT * sizeof(struct ieee80211_network), | 70 | kzalloc(MAX_NETWORK_COUNT * sizeof(struct ieee80211_network), |
71 | GFP_KERNEL); | 71 | GFP_KERNEL); |
72 | if (!ieee->networks) { | 72 | if (!ieee->networks) { |
73 | printk(KERN_WARNING "%s: Out of memory allocating beacons\n", | 73 | printk(KERN_WARNING "%s: Out of memory allocating beacons\n", |
@@ -75,9 +75,6 @@ static int ieee80211_networks_allocate(struct ieee80211_device *ieee) | |||
75 | return -ENOMEM; | 75 | return -ENOMEM; |
76 | } | 76 | } |
77 | 77 | ||
78 | memset(ieee->networks, 0, | ||
79 | MAX_NETWORK_COUNT * sizeof(struct ieee80211_network)); | ||
80 | |||
81 | return 0; | 78 | return 0; |
82 | } | 79 | } |
83 | 80 | ||
diff --git a/net/ieee80211/ieee80211_rx.c b/net/ieee80211/ieee80211_rx.c index ce28d571afac..d97e5412e31b 100644 --- a/net/ieee80211/ieee80211_rx.c +++ b/net/ieee80211/ieee80211_rx.c | |||
@@ -1304,12 +1304,11 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element | |||
1304 | case MFIE_TYPE_IBSS_DFS: | 1304 | case MFIE_TYPE_IBSS_DFS: |
1305 | if (network->ibss_dfs) | 1305 | if (network->ibss_dfs) |
1306 | break; | 1306 | break; |
1307 | network->ibss_dfs = | 1307 | network->ibss_dfs = kmemdup(info_element->data, |
1308 | kmalloc(info_element->len, GFP_ATOMIC); | 1308 | info_element->len, |
1309 | GFP_ATOMIC); | ||
1309 | if (!network->ibss_dfs) | 1310 | if (!network->ibss_dfs) |
1310 | return 1; | 1311 | return 1; |
1311 | memcpy(network->ibss_dfs, info_element->data, | ||
1312 | info_element->len); | ||
1313 | network->flags |= NETWORK_HAS_IBSS_DFS; | 1312 | network->flags |= NETWORK_HAS_IBSS_DFS; |
1314 | break; | 1313 | break; |
1315 | 1314 | ||
diff --git a/net/ieee80211/softmac/ieee80211softmac_auth.c b/net/ieee80211/softmac/ieee80211softmac_auth.c index 95e5287e12bb..0612015f1c78 100644 --- a/net/ieee80211/softmac/ieee80211softmac_auth.c +++ b/net/ieee80211/softmac/ieee80211softmac_auth.c | |||
@@ -216,10 +216,16 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth) | |||
216 | net->challenge_len = *data++; | 216 | net->challenge_len = *data++; |
217 | if (net->challenge_len > WLAN_AUTH_CHALLENGE_LEN) | 217 | if (net->challenge_len > WLAN_AUTH_CHALLENGE_LEN) |
218 | net->challenge_len = WLAN_AUTH_CHALLENGE_LEN; | 218 | net->challenge_len = WLAN_AUTH_CHALLENGE_LEN; |
219 | if (net->challenge != NULL) | 219 | kfree(net->challenge); |
220 | kfree(net->challenge); | 220 | net->challenge = kmemdup(data, net->challenge_len, |
221 | net->challenge = kmalloc(net->challenge_len, GFP_ATOMIC); | 221 | GFP_ATOMIC); |
222 | memcpy(net->challenge, data, net->challenge_len); | 222 | if (net->challenge == NULL) { |
223 | printkl(KERN_NOTICE PFX "Shared Key " | ||
224 | "Authentication failed due to " | ||
225 | "memory shortage.\n"); | ||
226 | spin_unlock_irqrestore(&mac->lock, flags); | ||
227 | break; | ||
228 | } | ||
223 | aq->state = IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE; | 229 | aq->state = IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE; |
224 | 230 | ||
225 | /* We reuse the work struct from the auth request here. | 231 | /* We reuse the work struct from the auth request here. |