Skip to content

Commit

Permalink
net/netfilter/x_tables.c: use kvmalloc() in xt_alloc_table_info()
Browse files Browse the repository at this point in the history
xt_alloc_table_info() basically opencodes kvmalloc() so use the library
function instead.

Link: http://lkml.kernel.org/r/20170531155145.17111-4-mhocko@kernel.org
Signed-off-by: Michal Hocko <mhocko@suse.com>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: Florian Westphal <fw@strlen.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Michal Hocko authored and Linus Torvalds committed Jul 12, 2017
1 parent 62b49c9 commit eacd86c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions net/netfilter/x_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,14 +1003,10 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size)
if ((SMP_ALIGN(size) >> PAGE_SHIFT) + 2 > totalram_pages)
return NULL;

if (sz <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER))
info = kmalloc(sz, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY);
if (!info) {
info = __vmalloc(sz, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY,
PAGE_KERNEL);
if (!info)
return NULL;
}
info = kvmalloc(sz, GFP_KERNEL);
if (!info)
return NULL;

memset(info, 0, sizeof(*info));
info->size = size;
return info;
Expand Down

0 comments on commit eacd86c

Please sign in to comment.