Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1480545
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/4] ATM-ZeitNet: Use kmalloc_array() in start_tx() |
| Date | 2016-09-10 11:10 +0200 |
| Message-ID | <sfMsq-6KX-11@gated-at.bofh.it> (permalink) |
| References | <sfMiJ-6sU-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 10 Sep 2016 09:55:53 +0200
* 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>
---
drivers/atm/zatm.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index cecfb94..d378ff2 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -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;
--
2.10.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 11:00 +0200 [PATCH 2/4] ATM-ZeitNet: Improve a size determination in zatm_open() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 11:10 +0200 [PATCH 4/4] ATM-ZeitNet: Fix indentation for one DPRINTK() call in start_rx() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 11:10 +0200 [PATCH 3/4] ATM-ZeitNet: Replace one kzalloc() call by kcalloc() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 11:10 +0200 [PATCH 1/4] ATM-ZeitNet: Use kmalloc_array() in start_tx() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 11:10 +0200 Re: [PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations David Miller <davem@davemloft.net> - 2016-09-11 06:50 +0200
csiph-web