staging: rtl8192e: use memdup_user to simplify code
[cascardo/linux.git] / drivers / staging / rtl8192e / rtllib_softmac.c
index 0cbf6f5..671fb5a 100644 (file)
@@ -604,7 +604,7 @@ static void rtllib_softmac_scan_wq(void *data)
 
        if (!ieee->ieee_up)
                return;
-       if (rtllib_act_scanning(ieee, true) == true)
+       if (rtllib_act_scanning(ieee, true))
                return;
 
        down(&ieee->scan_sem);
@@ -1202,7 +1202,7 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,
 
        if ((ieee->rtllib_ap_sec_type &&
            (ieee->rtllib_ap_sec_type(ieee) & SEC_ALG_TKIP)) ||
-           (ieee->bForcedBgMode == true)) {
+           ieee->bForcedBgMode) {
                ieee->pHTInfo->bEnableHT = 0;
                ieee->mode = WIRELESS_MODE_G;
        }
@@ -1535,7 +1535,7 @@ static void rtllib_associate_complete_wq(void *data)
        struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
                                        (&(ieee->PowerSaveControl));
        printk(KERN_INFO "Associated successfully\n");
-       if (ieee->is_silent_reset == 0) {
+       if (!ieee->is_silent_reset) {
                printk(KERN_INFO "normal associate\n");
                notify_wx_assoc_event(ieee);
        }
@@ -1572,7 +1572,7 @@ static void rtllib_associate_complete_wq(void *data)
        pPSC->LpsIdleCount = 0;
        ieee->link_change(ieee->dev);
 
-       if (ieee->is_silent_reset == 1) {
+       if (ieee->is_silent_reset) {
                printk(KERN_INFO "silent reset associate\n");
                ieee->is_silent_reset = 0;
        }
@@ -2005,7 +2005,7 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time)
                return 0;
 
        if (time) {
-               if (ieee->bAwakePktSent == true) {
+               if (ieee->bAwakePktSent) {
                        pPSC->LPSAwakeIntvl = 1;
                } else {
                        u8              MaxPeriod = 1;
@@ -2338,8 +2338,7 @@ inline int rtllib_rx_auth(struct rtllib_device *ieee, struct sk_buff *skb,
                                        }
 
                                        if (ieee->current_network.mode ==
-                                           IEEE_N_24G &&
-                                           bHalfSupportNmode == true) {
+                                           IEEE_N_24G && bHalfSupportNmode) {
                                                printk(KERN_INFO "======>enter "
                                                       "half N mode\n");
                                                ieee->bHalfWirelessN24GMode =
@@ -3591,14 +3590,9 @@ int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p,
                goto out;
        }
 
-       param = kmalloc(p->length, GFP_KERNEL);
-       if (param == NULL) {
-               ret = -ENOMEM;
-               goto out;
-       }
-       if (copy_from_user(param, p->pointer, p->length)) {
-               kfree(param);
-               ret = -EFAULT;
+       param = memdup_user(p->pointer, p->length);
+       if (IS_ERR(param)) {
+               ret = PTR_ERR(param);
                goto out;
        }