Sfoglia il codice sorgente

staging: csr: replace calls to kmalloc and memset with kzalloc

the kzalloc does allocates memory and sets the data at the memory
which is allocated to 0,

The driver does uses the kmalloc and memset at some points in the code
replace them with a single call to kzalloc

Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
Acked-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Devendra Naga 13 anni fa
parent
commit
7cd4e8c577
1 ha cambiato i file con 3 aggiunte e 7 eliminazioni
  1. 3 7
      drivers/staging/csr/sme_sys.c

+ 3 - 7
drivers/staging/csr/sme_sys.c

@@ -2813,12 +2813,11 @@ u8 blockack_session_start(unifi_priv_t *priv,
         }
         }
 
 
         /* create and populate the new BA session structure */
         /* create and populate the new BA session structure */
-        ba_session_tx = kmalloc(sizeof(ba_session_tx_struct), GFP_KERNEL);
+        ba_session_tx = kzalloc(sizeof(ba_session_tx_struct), GFP_KERNEL);
         if (!ba_session_tx) {
         if (!ba_session_tx) {
             unifi_error(priv, "%s: kmalloc failed for ba_session_tx\n", __FUNCTION__);
             unifi_error(priv, "%s: kmalloc failed for ba_session_tx\n", __FUNCTION__);
             return FALSE;
             return FALSE;
         }
         }
-        memset(ba_session_tx, 0, sizeof(ba_session_tx_struct));
 
 
         ba_session_tx->interfacePriv = interfacePriv;
         ba_session_tx->interfacePriv = interfacePriv;
         ba_session_tx->tID = tID;
         ba_session_tx->tID = tID;
@@ -2903,26 +2902,23 @@ u8 blockack_session_start(unifi_priv_t *priv,
             return FALSE;
             return FALSE;
         }
         }
 
 
-        ba_session_rx = kmalloc(sizeof(ba_session_rx_struct), GFP_KERNEL);
+        ba_session_rx = kzalloc(sizeof(ba_session_rx_struct), GFP_KERNEL);
         if (!ba_session_rx) {
         if (!ba_session_rx) {
             unifi_error(priv, "%s: kmalloc failed for ba_session_rx\n", __FUNCTION__);
             unifi_error(priv, "%s: kmalloc failed for ba_session_rx\n", __FUNCTION__);
             return FALSE;
             return FALSE;
         }
         }
-        memset(ba_session_rx, 0, sizeof(ba_session_rx_struct));
 
 
         ba_session_rx->wind_size = wind_size;
         ba_session_rx->wind_size = wind_size;
         ba_session_rx->start_sn = ba_session_rx->expected_sn = start_sn;
         ba_session_rx->start_sn = ba_session_rx->expected_sn = start_sn;
         ba_session_rx->trigger_ba_after_ssn = FALSE;
         ba_session_rx->trigger_ba_after_ssn = FALSE;
 
 
-        ba_session_rx->buffer = kmalloc(ba_session_rx->wind_size*sizeof(frame_desc_struct), GFP_KERNEL);
+        ba_session_rx->buffer = kzalloc(ba_session_rx->wind_size*sizeof(frame_desc_struct), GFP_KERNEL);
         if (!ba_session_rx->buffer) {
         if (!ba_session_rx->buffer) {
             kfree(ba_session_rx);
             kfree(ba_session_rx);
             unifi_error(priv, "%s: kmalloc failed for buffer\n", __FUNCTION__);
             unifi_error(priv, "%s: kmalloc failed for buffer\n", __FUNCTION__);
             return FALSE;
             return FALSE;
         }
         }
 
 
-        memset(ba_session_rx->buffer, 0, ba_session_rx->wind_size*sizeof(frame_desc_struct));
-
         INIT_WORK(&ba_session_rx->send_ba_err_task, uf_send_ba_err_wq);
         INIT_WORK(&ba_session_rx->send_ba_err_task, uf_send_ba_err_wq);
         if (timeout) {
         if (timeout) {
             ba_session_rx->timeout = timeout;
             ba_session_rx->timeout = timeout;