ATM-ZeitNet: Use kmalloc_array() in start_tx()
authorMarkus Elfring <elfring@users.sourceforge.net>
Sat, 10 Sep 2016 07:55:53 +0000 (09:55 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sun, 11 Sep 2016 04:46:06 +0000 (21:46 -0700)
* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/atm/zatm.c

index cecfb943762f6a1be4c7973e64583767a54edce6..d378ff2d3925e672f0f1d1d812184c36aca38b16 100644 (file)
@@ -998,8 +998,9 @@ static int start_tx(struct atm_dev *dev)
 
        DPRINTK("start_tx\n");
        zatm_dev = ZATM_DEV(dev);
-       zatm_dev->tx_map = kmalloc(sizeof(struct atm_vcc *)*
-           zatm_dev->chans,GFP_KERNEL);
+       zatm_dev->tx_map = kmalloc_array(zatm_dev->chans,
+                                        sizeof(*zatm_dev->tx_map),
+                                        GFP_KERNEL);
        if (!zatm_dev->tx_map) return -ENOMEM;
        zatm_dev->tx_bw = ATM_OC3_PCR;
        zatm_dev->free_shapers = (1 << NR_SHAPERS)-1;