Merge branch 'stable-3.2' into pandora-3.2
[pandora-kernel.git] / drivers / staging / wlags49_h2 / wl_priv.c
index 727ea8a..b3d2e17 100644 (file)
@@ -503,7 +503,8 @@ int wvlan_uil_send_diag_msg( struct uilreq *urq, struct wl_private *lp )
                                                return result;
                                        }
 
-                                       if ((data = kmalloc(urq->len, GFP_KERNEL)) != NULL) {
+                                       data = kmalloc(urq->len, GFP_KERNEL);
+                                       if (data != NULL) {
                                                memset( Descp, 0, sizeof( DESC_STRCT ));
                                                memcpy( data, urq->data, urq->len );
 
@@ -569,6 +570,7 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp )
        ltv_t                   *pLtv;
        bool_t                  ltvAllocated = FALSE;
        ENCSTRCT                sEncryption;
+       size_t                  len;
 
 #ifdef USE_WDS
        hcf_16                  hcfPort  = HCF_PORT_0;
@@ -617,7 +619,8 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp )
                                   LTV record, try to allocate it from the kernel stack.
                                   Otherwise, we just use our local LTV record. */
                                if( urq->len > sizeof( lp->ltvRecord )) {
-                                       if(( pLtv = (ltv_t *)kmalloc( urq->len, GFP_KERNEL )) != NULL ) {
+                                       pLtv = kmalloc(urq->len, GFP_KERNEL);
+                                       if (pLtv != NULL) {
                                                ltvAllocated = TRUE;
                                        } else {
                                                DBG_ERROR( DbgInfo, "Alloc FAILED\n" );
@@ -652,7 +655,7 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp )
                                        pLtv->u.u16[0]  = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
                                        break;
                                /* CFG_CNF_OWN_SSID currently same as CNF_DESIRED_SSID. Do we
-                                  need seperate storage for this? */
+                                  need separate storage for this? */
                                //case CFG_CNF_OWN_SSID:
                                case CFG_CNF_OWN_ATIM_WINDOW:
                                        lp->atimWindow  = pLtv->u.u16[0];
@@ -684,7 +687,8 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp )
                                        break;
                                case CFG_CNF_OWN_NAME:
                                        memset( lp->StationName, 0, sizeof( lp->StationName ));
-                                       memcpy( (void *)lp->StationName, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0]);
+                                       len = min_t(size_t, pLtv->u.u16[0], sizeof(lp->StationName));
+                                       strlcpy(lp->StationName, &pLtv->u.u8[2], len);
                                        pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
                                        break;
                                case CFG_CNF_LOAD_BALANCING:
@@ -1296,7 +1300,8 @@ int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp )
                                   LTV record, try to allocate it from the kernel stack.
                                   Otherwise, we just use our local LTV record. */
                                if( urq->len > sizeof( lp->ltvRecord )) {
-                                       if(( pLtv = (ltv_t *)kmalloc( urq->len, GFP_KERNEL )) != NULL ) {
+                                       pLtv = kmalloc(urq->len, GFP_KERNEL);
+                                       if (pLtv != NULL) {
                                                ltvAllocated = TRUE;
 
                                                /* Copy the command/length information into the new buffer. */
@@ -1797,6 +1802,7 @@ int wvlan_set_station_nickname(struct net_device *dev,
 {
         struct wl_private *lp = wl_priv(dev);
         unsigned long flags;
+       size_t len;
         int         ret = 0;
        /*------------------------------------------------------------------------*/
 
@@ -1807,8 +1813,8 @@ int wvlan_set_station_nickname(struct net_device *dev,
         wl_lock(lp, &flags);
 
         memset( lp->StationName, 0, sizeof( lp->StationName ));
-
-        memcpy( lp->StationName, extra, wrqu->data.length);
+       len = min_t(size_t, wrqu->data.length, sizeof(lp->StationName));
+       strlcpy(lp->StationName, extra, len);
 
         /* Commit the adapter parameters */
         wl_apply( lp );