From patchwork Sat Apr 8 12:11:36 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: 9671031 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 A628A60365 for ; Sat, 8 Apr 2017 12:11:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93AD828178 for ; Sat, 8 Apr 2017 12:11:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85622285E8; Sat, 8 Apr 2017 12:11:55 +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.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 2778D28178 for ; Sat, 8 Apr 2017 12:11:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752449AbdDHMLx (ORCPT ); Sat, 8 Apr 2017 08:11:53 -0400 Received: from mout.web.de ([212.227.15.3]:55534 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752446AbdDHMLw (ORCPT ); Sat, 8 Apr 2017 08:11:52 -0400 Received: from [192.168.1.2] ([77.181.115.245]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MI6F4-1cwHmW0n1C-003vHZ; Sat, 08 Apr 2017 14:11:38 +0200 Subject: [PATCH 1/3] IB/srp: Use kmalloc_array() in srp_alloc_req_data() From: SF Markus Elfring To: linux-rdma@vger.kernel.org, Bart Van Assche , Doug Ledford , Hal Rosenstock , Sean Hefty Cc: LKML , kernel-janitors@vger.kernel.org References: <50db1f1d-b689-1a9d-f6dd-a0f55169c75a@users.sourceforge.net> Message-ID: Date: Sat, 8 Apr 2017 14:11:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0 MIME-Version: 1.0 In-Reply-To: <50db1f1d-b689-1a9d-f6dd-a0f55169c75a@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:V1TuSyzCU5KYXg8bMPWZz/KDlzPnEfvLpawsq2ksmi726menLvQ OOixF4DagjZYMg5FcFNflzi1PPnWjLiu+99Tkf2qAqD/WikQe1nYw+bH+bTTE6K6mYm92pA qz0QtvvvVBOKag/PcImalBXQGeaTAObgW0ZWN0VmHaunpSFMlC8Ne8/bPV5AAfOpY1yT2jX riuWcTPWVWceil2cLUV4w== X-UI-Out-Filterresults: notjunk:1; V01:K0:sN1wtrvakrg=:271TUSG8ZiuVMQqyteZSCF ZoagfU3ec3wVoOTg2qFVz+uUDLXahTe3QimEf9qMsUtj0/EjeHHOnM10qUZ9CU3zRdJd7tYK0 1Pjxm31vxNb8SmqkzzFFoGGIh4qAwIoVJpFbh1zB4dVzcHo44iVLyAaIxN+TY/m0aSJevCkc0 TvSwLY1WZFlJ8QStw1711+ENfmLoHpSkvH6YjK/3Hfj4LZNtcp2zzNEGtgomA4ZtP8LkZbMjJ P6R/Fg+NNNOYCQ4P6pzgoku7kDVFD/zwbwXdm3pYy2FWfhfht/fPA1eWXHN5Zq64nsI1wEsrF uMyt6t/Mdzrj3oN4hhxs4Dknh4FxSUr/R5Patyp6KNqcnK5uLk4CrGcEeGYT9Vc3WgXCWApR8 v7HCnD+YPpga4GaH+2Oyx8EfAcC2lIZGfGZy7OWSztsdfLxbjsgLJmaY+M+snhBCrxRlkcJ4K VDr1micFtfOH/Xh7/XNh4hcKLh1pr3hugyBZUZSpiDWpH4aLZWRc3EVhkdi4IWBMpdu4hnGH/ xnPZZiStVi508vnzMnLMgErSdru8ZOyPvGnK2vYWZT3ZhUiaKoRAUPn0dpQ3nqq5MBjr8gNLt uQeIeBAt91lpTBj1abS8BhxWeS3E1OxCmu48yNajdmBDH2jUY1O15xSd6oiB2xYkUm0/yvYPe IPEJbmRH3nOtosvTAFYIfjNQRdyyHkMmVOFWwKRsqFmbltvlKpz0p7A4HHtzLqbzcnSdL0XIp dYoZVbY1RpD2vK/Xa54BDbQOBcy216kU/Rtu8bDJwjKC0JYEZhk6QOdBxSaHx5vQ02wqJFSic //fR4zK 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: Sat, 8 Apr 2017 11:11:44 +0200 Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "kmalloc_array". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/infiniband/ulp/srp/ib_srp.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index cee46266f434..cf8cb7206983 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -866,16 +866,17 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch) for (i = 0; i < target->req_ring_size; ++i) { req = &ch->req_ring[i]; - mr_list = kmalloc(target->mr_per_cmd * sizeof(void *), - GFP_KERNEL); + mr_list = kmalloc_array(target->mr_per_cmd, sizeof(void *), + GFP_KERNEL); if (!mr_list) goto out; if (srp_dev->use_fast_reg) { req->fr_list = mr_list; } else { req->fmr_list = mr_list; - req->map_page = kmalloc(srp_dev->max_pages_per_mr * - sizeof(void *), GFP_KERNEL); + req->map_page = kmalloc_array(srp_dev->max_pages_per_mr, + sizeof(void *), + GFP_KERNEL); if (!req->map_page) goto out; }