From patchwork Fri Feb 10 21:02:19 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: 9567507 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 906DF602B6 for ; Fri, 10 Feb 2017 21:02:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8015C285D6 for ; Fri, 10 Feb 2017 21:02:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 745A8285D9; Fri, 10 Feb 2017 21:02:51 +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 2BAE5285D6 for ; Fri, 10 Feb 2017 21:02:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932106AbdBJVCi (ORCPT ); Fri, 10 Feb 2017 16:02:38 -0500 Received: from mout.web.de ([212.227.17.12]:57578 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932102AbdBJVCg (ORCPT ); Fri, 10 Feb 2017 16:02:36 -0500 Received: from [192.168.1.2] ([77.182.113.129]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MRCnT-1cz9BB1NwF-00Ubf5; Fri, 10 Feb 2017 22:02:22 +0100 Subject: [PATCH 2/5] IB/hfi1: Use kcalloc() in hfi1_user_sdma_alloc_queues() 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: <71be9ebc-950f-7af2-4044-2c4b1ee44281@users.sourceforge.net> Date: Fri, 10 Feb 2017 22:02:19 +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:oenHJ4iTR4eBd0U7ZwlfiOlI5xWerZjHGtLyKeCTO5DM70sTpxf ytbdcdFZzKVkN+PU1vQ137dD2JwFCvUkkCUZeqo40QcCsBja82c9BTFOJw/ILeFHqSZ0nhy 1pF9EpMMt6qwBO6bESyLabsm+tCu9yt+l/wu0u/c72EvTnVKU1UWvS0tJH+2CHRfyRDPl2j Ncyui9HsCib5aAIw0JJmw== X-UI-Out-Filterresults: notjunk:1; V01:K0:fcRLzgcqdig=:o7k1wNkRN3KwYw8CzAvqJN e1h3/o2pll1UUJb3NU7pYWtRhxojsG9OitHac2iH08g+EfoW/yQz6PDq/OtgR1/cRQKCqlbnO IJX3jMDzqWi3zPqrDpH/F8WCZEsGJN2O5yhDhaYzuqWDi8+U8/JfrQMeBHrcABbVZaNIuq+I5 gZtYTmW98wwkRM7S8Dfce/4Z4ZePtjGqNNL8YlCDicsQCPZmkgrrtAtWhMOeaKiezj/euBsOI 2ePYhMIEyuA/9pc5YHH8xmBstQSlT3WWSOtNi7OWk8IaYWwZvJ2ubSagARaBHr6/XxeD1wbFU 3xnawhjA2feUmxPo/4MlBP4WEOKjzw+6G8iWiA8xz6oR9O0KU2h4WLAMp2bklff4gd3nSyu// +A9OCQMEqm/zNZEaaL6AQhTHl5TxRJ9W6Af5Lhuh0btfLfea6puMf1jJ4zYSn93J76xPkOY4v dJybUTcIHPYQ5ATP+FLlGr2PRMqhrnUS3TYVcQ50fwnaJ9r+r0rvN8CYSKj/napIjiL2iW/+t KVn++n/5BMm4UjbJUhjFHqRQMVfQh3Of+GCCBDFxtM8DX/RAKkcfoMjm++pPCImAZ26lxZp6Z DDG7ayqQ5hrxMnZ+LM3PF6FGQdc3igm4VTJGD5zjqAVxndX59/N82wJ+X6a2tLB9BJ8DK9Za2 cpLpgPdaDz8lAYsVl/Ad9hZ9wIPtA4oLmCewjMVkfHU9syS51UAlOphXMFytt+Dr7TOEcaMiJ o9r7HGchne1t718xambqSD4T7p/s/K5eNbkuJSF37+xOBveUffSYkiEh26shUw+IZ188+Imxk nD2bLmH 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 16:06:12 +0100 * Multiplications for the size determination of memory allocations indicated that array data structures 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_sdma.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/user_sdma.c b/drivers/infiniband/hw/hfi1/user_sdma.c index 7d22f8ee98ef..15194554a92b 100644 --- a/drivers/infiniband/hw/hfi1/user_sdma.c +++ b/drivers/infiniband/hw/hfi1/user_sdma.c @@ -400,13 +400,15 @@ int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt, struct file *fp) if (!pq) goto pq_nomem; - memsize = sizeof(*pq->reqs) * hfi1_sdma_comp_ring_size; - pq->reqs = kzalloc(memsize, GFP_KERNEL); + pq->reqs = kcalloc(hfi1_sdma_comp_ring_size, + sizeof(*pq->reqs), + GFP_KERNEL); if (!pq->reqs) goto pq_reqs_nomem; - memsize = BITS_TO_LONGS(hfi1_sdma_comp_ring_size) * sizeof(long); - pq->req_in_use = kzalloc(memsize, GFP_KERNEL); + pq->req_in_use = kcalloc(BITS_TO_LONGS(hfi1_sdma_comp_ring_size), + sizeof(*pq->req_in_use), + GFP_KERNEL); if (!pq->req_in_use) goto pq_reqs_no_in_use;