From: Loganaden Velvindron <logan@hackers.mu>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH] nf-next: x_tables: Replace kmalloc(s*n) with kmalloc_array(n,s)
Date: Wed, 10 Aug 2016 18:11:51 +0400 [thread overview]
Message-ID: <20160810141146.GA22890@void> (raw)
It is easier to check that the calculation doesn't wrap or return a smaller
allocation.
Signed-off-by: Loganaden Velvindron <logan@hackers.mu>
---
net/netfilter/x_tables.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index e0aa7c1..c8f20f2 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -1513,7 +1513,7 @@ xt_hook_ops_alloc(const struct xt_table *table, nf_hookfn *fn)
if (!num_hooks)
return ERR_PTR(-EINVAL);
- ops = kmalloc(sizeof(*ops) * num_hooks, GFP_KERNEL);
+ ops = kmalloc_array(num_hooks, sizeof(*ops), GFP_KERNEL);
if (ops == NULL)
return ERR_PTR(-ENOMEM);
--
2.9.2
next reply other threads:[~2016-08-10 18:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-10 14:11 Loganaden Velvindron [this message]
2016-08-11 23:13 ` [PATCH] nf-next: x_tables: Replace kmalloc(s*n) with kmalloc_array(n,s) Pablo Neira Ayuso
2016-08-12 7:12 ` Loganaden Velvindron
2016-08-12 7:19 ` Loganaden Velvindron
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=20160810141146.GA22890@void \
--to=logan@hackers.mu \
--cc=netfilter-devel@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;
as well as URLs for NNTP newsgroup(s).