netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-atm-general@lists.sourceforge.net, netdev@vger.kernel.org,
	Chas Williams <3chas3@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Julia Lawall <julia.lawall@lip6.fr>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: [PATCH 1/4] ATM-ZeitNet: Use kmalloc_array() in start_tx()
Date: Sat, 10 Sep 2016 11:00:09 +0200	[thread overview]
Message-ID: <4c3bc3b9-3bca-6a79-8093-1ee8d0c3ec8b@users.sourceforge.net> (raw)
In-Reply-To: <0b5381e1-d725-0706-1cc0-188df6c201f2@users.sourceforge.net>

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

  reply	other threads:[~2016-09-10  9:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-10  8:57 [PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations SF Markus Elfring
2016-09-10  9:00 ` SF Markus Elfring [this message]
2016-09-10  9:01 ` [PATCH 2/4] ATM-ZeitNet: Improve a size determination in zatm_open() SF Markus Elfring
2016-09-10  9:02 ` [PATCH 3/4] ATM-ZeitNet: Replace one kzalloc() call by kcalloc() SF Markus Elfring
2016-09-10  9:03 ` [PATCH 4/4] ATM-ZeitNet: Fix indentation for one DPRINTK() call in start_rx() SF Markus Elfring
2016-09-11  4:46 ` [PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4c3bc3b9-3bca-6a79-8093-1ee8d0c3ec8b@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=3chas3@gmail.com \
    --cc=julia.lawall@lip6.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-atm-general@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).