From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753671AbdBJVBg (ORCPT ); Fri, 10 Feb 2017 16:01:36 -0500 Received: from mout.web.de ([212.227.17.11]:51818 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753511AbdBJVBe (ORCPT ); Fri, 10 Feb 2017 16:01:34 -0500 Subject: [PATCH 1/5] IB/hfi1: Use kcalloc() in hfi1_user_exp_rcv_init() To: linux-rdma@vger.kernel.org, Dennis Dalessandro , Doug Ledford , Hal Rosenstock , Mike Marciniszyn , Sean Hefty References: <8a997282-09c7-0f9f-645e-d7c6e8c79e67@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <89f8b926-e272-71f2-f15e-3c322251da7b@users.sourceforge.net> Date: Fri, 10 Feb 2017 22:01:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <8a997282-09c7-0f9f-645e-d7c6e8c79e67@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:cKj/XLA/dDtmqYAiZzlA68WTD6maFxvRJkJUvBREOxn82b5OY4C TiJUJuifOWVC2t/bFN6PPFv4zVAaqj8QfJdMW7Xh9tavvow9ZfVwO75q8RaEhNMJUxoHvbN 8Kae8jSY5ALxJino0liP++s/ULn5i44Xn9nSN9JXUN2kCb2zsO6Q8TV8gKhpAa3FeximnW9 mFVz5q46S5uhdHJipTqOw== X-UI-Out-Filterresults: notjunk:1;V01:K0:tyA0TA+mixk=:lXDWaIQKdiBr3gG9A18+OX ho8FOg8v3iab+x4ERIm8tFkaVvDaae9ER2zWTkcgRmm0yM8PsMvUh/Fu7yvxcmbe+JshXvJwg PgK6n2s/roTe8bdpBVRH/mUtVFqnxkScoy5M1V9CQq6BPpKkB9q1b94SRAoHNLna93y4PcYAp Q7ZyXsl+BGy5VbW6SYAmbheI9gO3xmgDQMvKCIrABFmsC7J7EWbN2xQOr0s4bRswGS7TFE4ct 1RUSJ29NbyBLEuqUryT6A7VF8Emo0HcNDf1vXHpN909OhU/oePh3mOY0Ah8m1FkNZ0iOz5zrH DqMeEs+m+cCCRFVrZjFQaq3xcjI5VHfRQRNAlU5tMEy/vnqx6qYh7/YkqgFuyinWrSnRPJjlK +9VNEittjG192w7NHjD2yWb1IJJCFpqcBHffMxUORgYscaPQSGvukmmjKHjs8Rcbeynf4J41y Z2m3ytJFlliOiCjGiBSEn5AFQZjWhtecMdfVOi2PJnwN/+F+UZezfMWY7gKHLkBGjcSq2gdFH K2qT3mUw3snOzaaMwmWjn52+PpucnzJtMUTNaJW2z28uQxQwi+dy01V/T0N9f6OBVzHl5Gx9i AIuTZfWw1FQicLZOSA47rf8zKaE3OLE2jsutT3jRNdWDKCIRdlddSgqY6qVEeg/XsniQU+Vqe NYi/5m8+2wj90+V+JOx5SS5oxIZQOmJ2enwSrOuP3xK0npqWeHN3PaBRunI5u/2XqWQiCQEzZ 9kF39v8SDMnH1ylBD9Rt9hIlMbVsRiKl+fMoNhSFRVz1/CXQMNvB3Akpj/ETdR01yp2M9XrOd ck8Rz0p Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Thu, 9 Feb 2017 15:30:53 +0100 * A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus reuse the corresponding function "kcalloc". This issue was detected by using the Coccinelle software. * Replace the specification of a data type 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 --- drivers/infiniband/hw/hfi1/user_exp_rcv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/user_exp_rcv.c b/drivers/infiniband/hw/hfi1/user_exp_rcv.c index 64d26525435a..8ae0d26a34c6 100644 --- a/drivers/infiniband/hw/hfi1/user_exp_rcv.c +++ b/drivers/infiniband/hw/hfi1/user_exp_rcv.c @@ -199,8 +199,9 @@ int hfi1_user_exp_rcv_init(struct file *fp) if (!HFI1_CAP_UGET_MASK(uctxt->flags, TID_UNMAP)) { fd->invalid_tid_idx = 0; - fd->invalid_tids = kzalloc(uctxt->expected_count * - sizeof(u32), GFP_KERNEL); + fd->invalid_tids = kcalloc(uctxt->expected_count, + sizeof(*fd->invalid_tids), + GFP_KERNEL); if (!fd->invalid_tids) { ret = -ENOMEM; goto done; -- 2.11.1