From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762590AbdEVU6Z (ORCPT ); Mon, 22 May 2017 16:58:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55276 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762565AbdEVU6U (ORCPT ); Mon, 22 May 2017 16:58:20 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 019DCC059720 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vyasevic@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 019DCC059720 Reply-To: vyasevic@redhat.com Subject: Re: [PATCH 1/5] sctp: Use kmalloc_array() in sctp_init() References: <2845df67-d35d-536a-0a53-b2eb83fe1ba5@users.sourceforge.net> <24442429-99f7-7d83-5f56-f84776a81880@users.sourceforge.net> To: SF Markus Elfring , linux-sctp@vger.kernel.org, netdev@vger.kernel.org, "David S. Miller" , Neil Horman , Vlad Yasevich Cc: LKML , kernel-janitors@vger.kernel.org From: Vlad Yasevich Organization: Red Hat Message-ID: Date: Mon, 22 May 2017 16:57:58 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <24442429-99f7-7d83-5f56-f84776a81880@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 22 May 2017 20:58:00 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/22/2017 12:37 PM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Mon, 22 May 2017 17:20:11 +0200 > > * A multiplication for the size determination of a memory allocation > indicated that an array data structure should be processed. > Thus use the corresponding function "kmalloc_array". > > This issue was detected by using the Coccinelle software. > > * Replace the specification of a data structure by a pointer dereference > to make the corresponding size determination a bit safer according to > the Linux coding style convention. > > Signed-off-by: Markus Elfring Acked-by: Vlad Yasevich -vlad > --- > net/sctp/protocol.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c > index 989a900383b5..2b1a6215bd2f 100644 > --- a/net/sctp/protocol.c > +++ b/net/sctp/protocol.c > @@ -1442,6 +1442,6 @@ static __init int sctp_init(void) > > /* Allocate and initialize the endpoint hash table. */ > sctp_ep_hashsize = 64; > - sctp_ep_hashtable = > - kmalloc(64 * sizeof(struct sctp_hashbucket), GFP_KERNEL); > + sctp_ep_hashtable = kmalloc_array(64, sizeof(*sctp_ep_hashtable), > + GFP_KERNEL); > if (!sctp_ep_hashtable) { >