netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x_tables: Replace kmalloc(s*n) with kmalloc_array(n,s)
@ 2016-08-10 10:06 Loganaden Velvindron
  0 siblings, 0 replies; only message in thread
From: Loganaden Velvindron @ 2016-08-10 10:06 UTC (permalink / raw)
  To: netfilter-devel

Replace kmalloc(s*n) with kmalloc_array(n,s), thus making it
 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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-08-10 19:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-10 10:06 [PATCH] x_tables: Replace kmalloc(s*n) with kmalloc_array(n,s) Loganaden Velvindron

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).