From patchwork Wed Mar 8 13:17:29 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: 9611189 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 5977D6046A for ; Wed, 8 Mar 2017 14:12:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 961EB27FBB for ; Wed, 8 Mar 2017 14:12:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86D2A28210; Wed, 8 Mar 2017 14:12:10 +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 11E6027FBB for ; Wed, 8 Mar 2017 14:12:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753711AbdCHOLq (ORCPT ); Wed, 8 Mar 2017 09:11:46 -0500 Received: from mout.web.de ([212.227.15.14]:54190 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753546AbdCHOLj (ORCPT ); Wed, 8 Mar 2017 09:11:39 -0500 Received: from [192.168.1.2] ([92.228.144.238]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Mg7Zl-1cZrTz3aSL-00NPDI; Wed, 08 Mar 2017 14:17:30 +0100 Subject: [PATCH 17/26] IB/ocrdma: Use kmalloc_array() in ocrdma_create_srq() To: linux-rdma@vger.kernel.org, Devesh Sharma , Doug Ledford , Hal Rosenstock , Sean Hefty , Selvin Xavier References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: Date: Wed, 8 Mar 2017 14:17:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: X-Provags-ID: V03:K0:Fso/V9/YJGacS0DMfkRd810RuPuFA8EbNnVSKhXcGKs+rNtYA7C Jd205qI+j/5wNY6FUpYYlvKaKtdoOM8RLxgfJmAlrZM+ID/CMYR7+8ZtSkNEmpmk1ibVIm6 uq5uvtYi17sPH0Ll3fDC2PSBqWnUC0/DEcZ1ueTDO22Gsxd1q/Dt7QJQ9eLTnCxwXvzZ2Ok G9bV2ghLdpQfvrUGA1KiA== X-UI-Out-Filterresults: notjunk:1; V01:K0:VLK3YeuGoFs=:OiFHvLfidltUsEksCSma5C I5mYMAg+mcPVj+obmNdsHrO0zw7hDPTkJF3fnJQfROuwhgfOIeti5EyF+jQnivVHSV6MeGD/z C5Yz+kRfLvPVgVKq4A48JrKAwoBYggzD43OB5bThZ5yL73kPenbyZDD8VD4tTE/RLftevZ801 QpON34zOeowT20qhh44+L/QPDr2OYzEH/DPhxmpqqYL6PzU0vzPYStIPoIt+VLoBtw7wld7NB sJl1arpR9KJctzIcNUPwPCZoMVIvIzo2/MHsevh+RsaSr4nEoDf5YKVo/ifJU8yhTsPYP82W2 5vSF0QKPR52qHkwSFgahtTwUbEu4N9IcayZaNcG08NZJZb7RJgun0EUf7JPTrAzB4pKOZSaTW dpfjp7L3KxuscJst5yCM671PpvhM7bYdHCKZc/OC4OkyEjVLj6Oek86RbWjTxiuEeNz/13U+d Ocux7gHgkQ8X4SdRZu2jpSj6WcyGHVrj/RnkN9HUZkQwJWPwz33VJMBgP6411r63WgVIl2EVZ zEE+kKYXKtJEWC9BMSbaP4TLqeRxGi1++8yfVeZf0+yQRaloR+2oYS1E0gXVlCSBZ+GEB7I6r CQBCApmiVPgAXli+kBN7EsMT2ZCmmb8nz67JM2FJLJM25WXMB+vU4OGQeCXL7HT1Q9XjlJmyB 8YPZd6kaQwn3jC+r/pUSlmW54mKlAPadUdaipkbM2Szl4t7OC06J4LjrvXE9xbGcK9TxqTsyA 6yrPsVKhK31XJl08QwpJW9/qGia06TTuPdla3cHs6VZ1AQA1IIexG5hbS5srW0Z99awXOXK9J WE2pNVa 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: Wed, 8 Mar 2017 08:45:31 +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 "kmalloc_array". 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/ocrdma/ocrdma_verbs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c index bc9fb144e57b..ef670ac1cbe9 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c @@ -1910,8 +1910,9 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, srq->bit_fields_len = (srq->rq.max_cnt / 32) + (srq->rq.max_cnt % 32 ? 1 : 0); - srq->idx_bit_fields = - kmalloc(srq->bit_fields_len * sizeof(u32), GFP_KERNEL); + srq->idx_bit_fields = kmalloc_array(srq->bit_fields_len, + sizeof(*srq->idx_bit_fields), + GFP_KERNEL); if (srq->idx_bit_fields == NULL) goto arm_err; memset(srq->idx_bit_fields, 0xff,