Skip to content

Commit e808bb6

Browse files
elfringdavem330
authored andcommitted
ATM-iphase: Use kmalloc_array() in tx_init()
* Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "kmalloc_array". This issue was detected by using the Coccinelle software. * Replace the specification of data types by pointer dereferences 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>
1 parent 171a6c5 commit e808bb6

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎drivers/atm/iphase.c‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,7 +1975,9 @@ static int tx_init(struct atm_dev *dev)
19751975
buf_desc_ptr++;
19761976
tx_pkt_start += iadev->tx_buf_sz;
19771977
}
1978-
iadev->tx_buf = kmalloc(iadev->num_tx_desc*sizeof(struct cpcs_trailer_desc), GFP_KERNEL);
1978+
iadev->tx_buf = kmalloc_array(iadev->num_tx_desc,
1979+
sizeof(*iadev->tx_buf),
1980+
GFP_KERNEL);
19791981
if (!iadev->tx_buf) {
19801982
printk(KERN_ERR DEV_LABEL " couldn't get mem\n");
19811983
goto err_free_dle;
@@ -1995,8 +1997,9 @@ static int tx_init(struct atm_dev *dev)
19951997
sizeof(*cpcs),
19961998
DMA_TO_DEVICE);
19971999
}
1998-
iadev->desc_tbl = kmalloc(iadev->num_tx_desc *
1999-
sizeof(struct desc_tbl_t), GFP_KERNEL);
2000+
iadev->desc_tbl = kmalloc_array(iadev->num_tx_desc,
2001+
sizeof(*iadev->desc_tbl),
2002+
GFP_KERNEL);
20002003
if (!iadev->desc_tbl) {
20012004
printk(KERN_ERR DEV_LABEL " couldn't get mem\n");
20022005
goto err_free_all_tx_bufs;
@@ -2124,7 +2127,9 @@ static int tx_init(struct atm_dev *dev)
21242127
memset((caddr_t)(iadev->seg_ram+i), 0, iadev->num_vc*4);
21252128
vc = (struct main_vc *)iadev->MAIN_VC_TABLE_ADDR;
21262129
evc = (struct ext_vc *)iadev->EXT_VC_TABLE_ADDR;
2127-
iadev->testTable = kmalloc(sizeof(long)*iadev->num_vc, GFP_KERNEL);
2130+
iadev->testTable = kmalloc_array(iadev->num_vc,
2131+
sizeof(*iadev->testTable),
2132+
GFP_KERNEL);
21282133
if (!iadev->testTable) {
21292134
printk("Get freepage failed\n");
21302135
goto err_free_desc_tbl;

0 commit comments

Comments
 (0)