From patchwork Fri Feb 10 21:01:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9567501 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1796B602B6 for ; Fri, 10 Feb 2017 21:01:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05494285D6 for ; Fri, 10 Feb 2017 21:01:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC576285D9; Fri, 10 Feb 2017 21:01:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D014285D6 for ; Fri, 10 Feb 2017 21:01:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753628AbdBJVBf (ORCPT ); Fri, 10 Feb 2017 16:01:35 -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 Received: from [192.168.1.2] ([77.182.113.129]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MOzoR-1cWXYo2nI7-006QiT; Fri, 10 Feb 2017 22:01:26 +0100 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> 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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;