From: Frank Zago Date: Mon, 7 Jul 2014 23:09:04 +0000 (-0500) Subject: LU-5304: no need to zero out the allocated memory when GFP_ZERO is set X-Git-Tag: 2.6.51~99 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=e270894db5e357193a7dfd0f998dba37e68c1fc3;hp=35c686077094fb92a1f15368e27d5f625c27c4f7 LU-5304: no need to zero out the allocated memory when GFP_ZERO is set The kernel will zero out the memory allocated when GFP_ZERO is set, so no need to zero it out again. It is possible the original intent was to memset the allocated memory if GFP_ZERO was not set. However the only two existing callers of this function already set GFP_ZERO. Signed-off-by: Frank Zago Change-Id: Ia7f365f91aa2ce7a302e4f794706c978222317bb Reviewed-on: http://review.whamcloud.com/11011 Reviewed-by: Patrick Farrell Reviewed-by: Andreas Dilger Tested-by: Jenkins Reviewed-by: James Simmons Reviewed-by: Liang Zhen Tested-by: Maloo Reviewed-by: Dmitry Eremin --- diff --git a/libcfs/libcfs/linux/linux-mem.c b/libcfs/libcfs/linux/linux-mem.c index cc18de2..05c160d 100644 --- a/libcfs/libcfs/linux/linux-mem.c +++ b/libcfs/libcfs/linux/linux-mem.c @@ -45,14 +45,8 @@ void * cfs_cpt_malloc(struct cfs_cpt_table *cptab, int cpt, size_t nr_bytes, unsigned int flags) { - void *ptr; - - ptr = kmalloc_node(nr_bytes, flags, - cfs_cpt_spread_node(cptab, cpt)); - if (ptr != NULL && (flags & __GFP_ZERO) != 0) - memset(ptr, 0, nr_bytes); - - return ptr; + return kmalloc_node(nr_bytes, flags, + cfs_cpt_spread_node(cptab, cpt)); } EXPORT_SYMBOL(cfs_cpt_malloc);