mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Pan Bian <bianpan2016@163.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 1/4] dcbnl: Use kmalloc_array() in dcbnl_build_peer_app()
Date: Sat, 28 Jan 2017 10:33:44 +0100	[thread overview]
Message-ID: <ee60540c-0e30-4abf-2bf0-00ab5fe2aab8@users.sourceforge.net> (raw)
In-Reply-To: <ab981a3f-e73e-9bef-09c5-9c6d077aef00@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 27 Jan 2017 22:30:09 +0100

* 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 structure 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>
---
 net/dcb/dcbnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 3202d75329b5..76fd727e2eb4 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -990,7 +990,7 @@ static int dcbnl_build_peer_app(struct net_device *netdev, struct sk_buff* skb,
 	 */
 	err = ops->peer_getappinfo(netdev, &info, &app_count);
 	if (!err && app_count) {
-		table = kmalloc(sizeof(struct dcb_app) * app_count, GFP_KERNEL);
+		table = kmalloc_array(app_count, sizeof(*table), GFP_KERNEL);
 		if (!table)
 			return -ENOMEM;
 
-- 
2.11.0

  reply	other threads:[~2017-01-28  9:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-28  9:32 [PATCH 0/4] DCB netlink: Fine-tuning for some function implementations SF Markus Elfring
2017-01-28  9:33 ` SF Markus Elfring [this message]
2017-01-28  9:34 ` [PATCH 2/4] dcbnl: Adjust four function calls together with a variable assignment SF Markus Elfring
2017-01-28  9:36 ` [PATCH 3/4] dcbnl: Adjust five checks for null pointers SF Markus Elfring
2017-01-28  9:37 ` [PATCH 4/4] dcbnl: Add some spaces for better code readability SF Markus Elfring

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=ee60540c-0e30-4abf-2bf0-00ab5fe2aab8@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=bianpan2016@163.com \
    --cc=davem@davemloft.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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

Powered by JetHome