Files
Linux/net/xfrm/xfrm_hash.c
T
Joonwoo Park dcaee95a1b [IPSEC]: kmalloc + memset conversion to kzalloc
2007/11/26, Patrick McHardy <[email protected]>:
> How about also switching vmalloc/get_free_pages to GFP_ZERO
> and getting rid of the memset entirely while you're at it?
>

xfrm_hash: kmalloc + memset conversion to kzalloc
fix to avoid memset entirely.

Signed-off-by: Joonwoo Park <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
2008-01-28 14:55:05 -08:00

40 lines
806 B
C

/* xfrm_hash.c: Common hash table code.
*
* Copyright (C) 2006 David S. Miller ([email protected])
*/
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/bootmem.h>
#include <linux/vmalloc.h>
#include <linux/slab.h>
#include <linux/xfrm.h>
#include "xfrm_hash.h"
struct hlist_head *xfrm_hash_alloc(unsigned int sz)
{
struct hlist_head *n;
if (sz <= PAGE_SIZE)
n = kzalloc(sz, GFP_KERNEL);
else if (hashdist)
n = __vmalloc(sz, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL);
else
n = (struct hlist_head *)
__get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO,
get_order(sz));
return n;
}
void xfrm_hash_free(struct hlist_head *n, unsigned int sz)
{
if (sz <= PAGE_SIZE)
kfree(n);
else if (hashdist)
vfree(n);
else
free_pages((unsigned long)n, get_order(sz));
}