From patchwork Fri Apr 21 18:21:12 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: 9693377 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 10BBB6038D for ; Fri, 21 Apr 2017 18:26:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0601028636 for ; Fri, 21 Apr 2017 18:26:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF0FF28654; Fri, 21 Apr 2017 18:26:21 +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 7B84728636 for ; Fri, 21 Apr 2017 18:26:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161111AbdDUSZV (ORCPT ); Fri, 21 Apr 2017 14:25:21 -0400 Received: from mout.web.de ([212.227.15.4]:59468 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423562AbdDUSVv (ORCPT ); Fri, 21 Apr 2017 14:21:51 -0400 Received: from [192.168.1.2] ([77.182.39.184]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MWeGR-1cUKkK2MTj-00Xwfx; Fri, 21 Apr 2017 20:21:23 +0200 Subject: [PATCH v2 01/17] IB/mlx4: Use kcalloc() in mlx4_ib_alloc_pv_bufs() From: SF Markus Elfring To: Doug Ledford , Hal Rosenstock , Leon Romanovsky , Majd Dibbiny , Matan Barak , Sean Hefty , Yishai Hadas , linux-rdma@vger.kernel.org Cc: LKML , kernel-janitors@vger.kernel.org References: <1935365a-bd7c-461e-6a84-0c5d3a501fff@users.sourceforge.net> <1492720654.3041.16.camel@redhat.com> Message-ID: <4ab0af63-1ea3-acd5-75ba-1992d8ae9924@users.sourceforge.net> Date: Fri, 21 Apr 2017 20:21:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-Provags-ID: V03:K0:cE+xZR+VmGAqq3w8jEJ3SZgaIkmtMJVVOi2Hn3yMpmFaF2p2ajd R2fk+lL6iNZDhRJU7zR6NQVXM2E0LmsVzSxhc6LQV8LF5ZX4Al6kye3jLn1r9r4jND9mdm5 638RWWZL4GOTFjqW4/SOhqT1G5l53jXHsortJRD3MQsKkjYWnLp706iJxnq/W5A7JjZaIfo iubgRjijbbAVPGh6/poXw== X-UI-Out-Filterresults: notjunk:1; V01:K0:DcxVI3MeL3E=:C7KtVU7Kczml9A1ZHtjzON 5531BQcYdJfIMdsMebtZSmNL0oVuZB2/dexl7UkqKkweH0AtUgmc4JxDpK9GFxo1261tRI6/w MJLVjnIm/scb4ZsOI68Ae1LPhhKNrM+DRlkedwSbONCO9yvwpicbkR0B/TFgUqQaLpCUVsH7o uxJrT1dEzTEmDLK78UU3MPvW9/ieDqieOPtjpsTnVllTw3T78h4iQAxbAmVAHVwBu2tzR5/tq YOZpexsljeQaiwRYNlzVfgX7AnsPR87qeTniV0PZ8tjF/wPeXVxiSiaOFsQ2iVYWVvQzT+I4k hly6AiHLHYHjz07cTen1eq2pPmt/50STZQf7AZ/r3ISZgWQicMNuwWcFp6ZDpogP+L+18LotK Mo9+DlmhrdJlRA1jx7qYHCMSSK5edMPuJt04MqINv/NC6z12yNv1aurLbh/amLT5mWylWyWn/ pEPDyHUVNRBJPOWa9S6pcq9eV4uz2w0xFMdYyCZC1EgzJYJ4PwUuU6sUZ52Ai6PQPBXrNMwcv QtDnQJe7CKPnfSQtkJDkHPmDpFz0gaSb6XndGSwjEecyjaXpa0sqPDIEkxVRd3V6Kdb58vmtD OX4VPBRIgQ3YYulCSfRTyEMZtrbQ7VhU9dyESXZdVOHtgOE7aeryqSA9auCXj4k1TL70Kwuwl Dlg7x51O0ydw51lJEe0iIXTl9i3I8AC0no5pn39h1WoX0ifxVd0+6LFlhYFRCbFFbCKUu5uXO LqU7MbsxUQPQqv5INhZF8z21zTm5uRRB1SLbQfL3+UyOxQ0rnNUwG5yxrxHX2niKtbt+K+n4w ps4hgsa 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, 21 Apr 2017 10:21:01 +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 "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;