Skip to content

Commit

Permalink
ATM-ZeitNet: Use kmalloc_array() in start_tx()
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
elfring authored and davem330 committed Sep 11, 2016
1 parent 0ba8abb commit 32230ac
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/atm/zatm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 32230ac

Please sign in to comment.