From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753081AbcADJJu (ORCPT ); Mon, 4 Jan 2016 04:09:50 -0500 Received: from www.osadl.org ([62.245.132.105]:60578 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751941AbcADJJs (ORCPT ); Mon, 4 Jan 2016 04:09:48 -0500 From: Nicholas Mc Guire To: Larry Finger Cc: Florian Schilhabel , Greg Kroah-Hartman , Luis de Bethencourt , Gamze POLAT , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH] staging: rtl8712: consolidate kmalloc/memset 0 of array to kcalloc Date: Mon, 4 Jan 2016 10:05:49 +0100 Message-Id: <1451898349-5388-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an API consolidation only. The use of kmalloc of an array of elements of equal size + memset to 0 of the same is equivalent to kcalloc. Signed-off-by: Nicholas Mc Guire --- Found by coccinelle script (relaxed version of scripts/coccinelle/api/alloc/kzalloc-simple.cocci) Patch was compile tested with: x86_64_defconfig + CONFIG_STAGING=y, CONFIG_R8712U=m Patch is against linux-next (localversion-next is -next-20160104) drivers/staging/rtl8712/rtl871x_recv.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_recv.c b/drivers/staging/rtl8712/rtl871x_recv.c index 4ff5301..aa841bf 100644 --- a/drivers/staging/rtl8712/rtl871x_recv.c +++ b/drivers/staging/rtl8712/rtl871x_recv.c @@ -72,14 +72,12 @@ sint _r8712_init_recv_priv(struct recv_priv *precvpriv, _init_queue(&precvpriv->recv_pending_queue); precvpriv->adapter = padapter; precvpriv->free_recvframe_cnt = NR_RECVFRAME; - precvpriv->pallocated_frame_buf = kmalloc(NR_RECVFRAME * + precvpriv->pallocated_frame_buf = kcalloc(NR_RECVFRAME, sizeof(union recv_frame) + RXFRAME_ALIGN_SZ, GFP_ATOMIC); if (precvpriv->pallocated_frame_buf == NULL) return _FAIL; kmemleak_not_leak(precvpriv->pallocated_frame_buf); - memset(precvpriv->pallocated_frame_buf, 0, NR_RECVFRAME * - sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf + RXFRAME_ALIGN_SZ - ((addr_t)(precvpriv->pallocated_frame_buf) & -- 2.1.4