From patchwork Sat Feb 18 20:47:53 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: 9581237 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 A7192604A4 for ; Sat, 18 Feb 2017 20:54:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96212284FE for ; Sat, 18 Feb 2017 20:54:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8782E28768; Sat, 18 Feb 2017 20:54:59 +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 18641284FE for ; Sat, 18 Feb 2017 20:54:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754293AbdBRUy5 (ORCPT ); Sat, 18 Feb 2017 15:54:57 -0500 Received: from mout.web.de ([212.227.15.14]:58869 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754231AbdBRUy4 (ORCPT ); Sat, 18 Feb 2017 15:54:56 -0500 Received: from [192.168.1.2] ([77.181.107.93]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LnBTZ-1c9QTs14ZR-00hK0M; Sat, 18 Feb 2017 21:48:01 +0100 Subject: [PATCH 01/29] IB/mlx4: Use kcalloc() in mlx4_ib_alloc_pv_bufs() To: linux-rdma@vger.kernel.org, Doug Ledford , Hal Rosenstock , Leon Romanovsky , Matan Barak , Sean Hefty , Yishai Hadas References: <1935365a-bd7c-461e-6a84-0c5d3a501fff@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: Date: Sat, 18 Feb 2017 21:47:53 +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: <1935365a-bd7c-461e-6a84-0c5d3a501fff@users.sourceforge.net> X-Provags-ID: V03:K0:1wIaecZBA3vK5/tC0rdkcRi+b0dzpvqjEr4f05ZV7Y9T7/2ju8y FTult1Onzq6oBkbOiCbxghFiCVTIGirC8cM8XkN65H6KG2p1IWCsLwKXnJvA498omHUJbOq HuTw5jwertlomnp+AfWCULi8DNyoDBn+4U72Qz+y5miiHKzHKes67c+/M8nb+XCf7ZE9R1h 0jYEeXcyqmDu2v7UX3KzQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:ha38Lf3cOeY=:NslSVyysHPUtCXMD2IsBUl zx/vB7j/9vYyCnCpaliBXFiQzw1p/cCDeZjY//1NSb99wcRKpTnWs5jl3D+hHBdZk0ETZrgn2 /jy7U2Uzd7M8MX+Gi3pkaEAYdwk4oluqRnx7uhLZtGa+aEcymwFp+aZEBgBR2MfWCkmDy3sia hS8OTX9zWHUrMc/EdHKjobYfR51OEqYebnQxCwFtB8p070RkThXM0mtChWWfq4eMwwjepLVYG K+Hvl56P3Ljih/kYUdPCqyWHJsTdoJ91Ap7UYOcLGkrCBAd5PHaPFR26lF9XPPTv+DeGxP4Z9 vW6mTzG/Z26rF8ZTx0/lqVPL6Osk0XdSK20B+53UbvHDA9/BKxPLXeMaznQFdNaLdoVmuf+di Dqn3owkveRgH/Wa1QpRHODpf9+jWBd91WUmVWsCxkeDkS8+dk/+AV2HNWf+YvOFUUdP/vefWI ci2f98b4TWXd9AtZZWAY++zKYU/HafG/y1Oz1brKsb5yvhoiaX/oww6thszKa6t0xWvfKyu3P BUg2bvyZjNlQNGkripU4zW+fSsfWd896tfxKrixNs81OTry+hwgvfimLeoYQXLE0GlL7ZLOJx iGw6kJgRTuw6Qi0Q9gC0sJ/QM3itHpwQKVmRL1Am8HfrSwk3NtCpMYPwC8j1YgiuTuM6bRBt8 1FV9a8nOtYRwMMmA6f2oQzplrBRaCMh0wP+2Uf5X00jq8Xc0sAQ6slp6nACdqxJuQPA/TyviY TIakLTqABzsVFFl7R6Pnpdgxn0cvOk09gIWGz+S1TLlxyMolVUND5Af73MqgrN7dBrrwLI5bk kKGClYm 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: Fri, 17 Feb 2017 20:00:34 +0100 * A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kcalloc". 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 Reviewed-by: Majd Dibbiny --- drivers/infiniband/hw/mlx4/mad.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c index db564ccc0f92..61bd81baeb29 100644 --- a/drivers/infiniband/hw/mlx4/mad.c +++ b/drivers/infiniband/hw/mlx4/mad.c @@ -1600,8 +1600,8 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx, return -EINVAL; tun_qp = &ctx->qp[qp_type]; - - tun_qp->ring = kzalloc(sizeof (struct mlx4_ib_buf) * MLX4_NUM_TUNNEL_BUFS, + tun_qp->ring = kcalloc(MLX4_NUM_TUNNEL_BUFS, + sizeof(*tun_qp->ring), GFP_KERNEL); if (!tun_qp->ring) return -ENOMEM;