]> git.proxmox.com Git - mirror_ubuntu-kernels.git/blobdiff - drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
Staging: Use kcalloc or kzalloc
[mirror_ubuntu-kernels.git] / drivers / staging / rtl8192u / ieee80211 / ieee80211_softmac.c
index d54e3a77423ff2f79b70c47f312e7b4af7066341..a6955e2b45c4afac5b289e5dd98bd088a5033720 100644 (file)
@@ -1579,7 +1579,9 @@ static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen)
 
                if(*(t++) == MFIE_TYPE_CHALLENGE){
                        *chlen = *(t++);
-                       *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC);
+                       *challenge = kmalloc(*chlen, GFP_ATOMIC);
+                       if (!*challenge)
+                               return -ENOMEM;
                        memcpy(*challenge, t, *chlen);
                }
        }
@@ -1713,7 +1715,8 @@ ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
        //IEEE80211DMESG("Rx probe");
        ieee->softmac_stats.rx_auth_rq++;
 
-       if ((status = auth_rq_parse(skb, dest))!= -1){
+       status = auth_rq_parse(skb, dest);
+       if (status != -1) {
                ieee80211_resp_to_auth(ieee, status, dest);
        }
        //DMESG("Dest is "MACSTR, MAC2STR(dest));
@@ -2720,10 +2723,9 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee)
          ieee->seq_ctrl[i] = 0;
        }
 #ifdef ENABLE_DOT11D
-       ieee->pDot11dInfo = kmalloc(sizeof(RT_DOT11D_INFO), GFP_ATOMIC);
+       ieee->pDot11dInfo = kzalloc(sizeof(RT_DOT11D_INFO), GFP_ATOMIC);
        if (!ieee->pDot11dInfo)
                IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc memory for DOT11D\n");
-       memset(ieee->pDot11dInfo, 0, sizeof(RT_DOT11D_INFO));
 #endif
        //added for  AP roaming
        ieee->LinkDetectInfo.SlotNum = 2;
@@ -3074,8 +3076,7 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
 
                ieee80211_crypt_delayed_deinit(ieee, crypt);
 
-               new_crypt = (struct ieee80211_crypt_data *)
-                       kmalloc(sizeof(*new_crypt), GFP_KERNEL);
+               new_crypt = kmalloc(sizeof(*new_crypt), GFP_KERNEL);
                if (new_crypt == NULL) {
                        ret = -ENOMEM;
                        goto done;
@@ -3207,7 +3208,7 @@ int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_poin
                goto out;
        }
 
-       param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL);
+       param = kmalloc(p->length, GFP_KERNEL);
        if (param == NULL){
                ret = -ENOMEM;
                goto out;