From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935936AbdEVQii (ORCPT ); Mon, 22 May 2017 12:38:38 -0400 Received: from mout.web.de ([212.227.15.3]:49779 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934590AbdEVQie (ORCPT ); Mon, 22 May 2017 12:38:34 -0400 Subject: [PATCH 1/5] sctp: Use kmalloc_array() in sctp_init() From: SF Markus Elfring To: linux-sctp@vger.kernel.org, netdev@vger.kernel.org, "David S. Miller" , Neil Horman , Vlad Yasevich Cc: LKML , kernel-janitors@vger.kernel.org References: <2845df67-d35d-536a-0a53-b2eb83fe1ba5@users.sourceforge.net> Message-ID: <24442429-99f7-7d83-5f56-f84776a81880@users.sourceforge.net> Date: Mon, 22 May 2017 18:37:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <2845df67-d35d-536a-0a53-b2eb83fe1ba5@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:wbcdswZkpIqWemuYndah3hbaqlxMvKIgXEJKERighMlahIgRc19 A8bKU0dY9IjVZjufPsx8uqydODpYlGH240C7g1reB2KDjgHvWl6sCDmFA6na7b0S4ANBcJc 5EyCUza+6QkpXRJ/A6Ws4BaGKSbPFKjpVfYXuvFIHnJ6hK7sOrK6m35Ky2V7hroxNB+YNw/ CVIsRtxCXZrBgUoiz7h7g== X-UI-Out-Filterresults: notjunk:1;V01:K0:bzCNGfdt6yE=:JNU7hbwbUPpIG9u5LzpIwB lMri8yGDfimazafuxuVWF9nLmIEfxwmUzC+0Lwzqt1/DcoLWwRrFS/Pfp4bc1DlT2QdNErne0 Gq8WaGvQhHVl49ygY+af7b4TwP3fGCzT9UcCdQftzisUqcukX9tmkXP9KgN5Ww1FhzfOrzUc7 sS7J0O6T93/jbFDc6WAB9OiUp89ldl/syEBxpUgR4CStgpqn63I+9KqnUtEJpCCe2VJtXDVWT lhg3AYB5A2uczxIBNHbYUMvfQKhYfP3cu69Rpv15NYpriBIiPEz4ccMsQoBnbrIl27v7v35M5 4iT3RzOG4a0SLVrb4r6SNWoSEy/D//erPBrEcpi1TtgbRKz0ecQGQn8+6Be8FEV1mCwxEu4U8 O9u5G00O6521JFW6K36YdoHW769pIk7dox4L9hbmCSD+bV3P/0pHTCGbXD+OhiCffShj5NgSF BZ4mZDCxsg39UDNLoRM3Bzf0Il9EkFOz1LshzBBombzBN6K0Mh2uM5ebsmnJL5AkL1+0ARL/S e7LdAqa+033qpS+1aAjmjh2lGfcHImVahKN6xqEX9E7PkDoLoMGlJOroC1eLB4ro190kPcTHR q2jBCoR7zhzTamBvaH52KXfGG/C/4Ylpt8SOYhSIBY+lf59BRw4LVL0o8zTvI4/zLlGZtbNX0 +ZG3dKrJ/q9JInDJ3qikP+qssHq5AtISQBvdNMuW50tWFhAUK99W+5MzgxD152tABZa2itT1p zKrwynnHuwqCa/pXUxB5kgxUk/Y3RxoXnBbOXnBWRSEeEXLyruzzDXhma+gum86HnHuq3RxQH +Iv7IKa Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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) { -- 2.13.0