From patchwork Sat Apr 22 14:45:07 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: 9694415 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 A786E601E9 for ; Sat, 22 Apr 2017 14:45:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8DA428174 for ; Sat, 22 Apr 2017 14:45:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DBF028335; Sat, 22 Apr 2017 14:45:40 +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 56DBF28174 for ; Sat, 22 Apr 2017 14:45:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424636AbdDVOp1 (ORCPT ); Sat, 22 Apr 2017 10:45:27 -0400 Received: from mout.web.de ([212.227.15.3]:55124 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424492AbdDVOpZ (ORCPT ); Sat, 22 Apr 2017 10:45:25 -0400 Received: from [192.168.1.2] ([77.181.100.232]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0M09eO-1cA6B808qK-00uEiy; Sat, 22 Apr 2017 16:45:10 +0200 Subject: [PATCH v2 06/12] IB/ocrdma: Use kmalloc_array() in ocrdma_create_srq() From: SF Markus Elfring To: Devesh Sharma , Doug Ledford , Hal Rosenstock , Sean Hefty , Selvin Xavier , Yuval Shaia , linux-rdma@vger.kernel.org Cc: LKML , kernel-janitors@vger.kernel.org References: <1492720999.3041.18.camel@redhat.com> <86425035-7da8-d2b1-8544-d4f7540d50c6@users.sourceforge.net> Message-ID: <899edbe6-3248-d2de-0d09-f9ffef952ec8@users.sourceforge.net> Date: Sat, 22 Apr 2017 16:45:07 +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: <86425035-7da8-d2b1-8544-d4f7540d50c6@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:V7ukeTJlH156CgPhZJPOsPowzWe/N9xE07lDqESHKjOQlg0/vYI 6Y3nguwK0238MFYxKfYwv5nD6et8wDfBeH9arD2Uu4bZDcdFRRHRkMyNpCsj1thjtBNAB2x czn41c0N/EMig8CYArKurA4MS+Vc3Y6sF8ma0rb3j/YARtjFqOjHD9o6vzcVoqHLLwmmsul BBPu6ri45BK0ZBKKfUXtA== X-UI-Out-Filterresults: notjunk:1; V01:K0:Ys5aa1ck598=:7yaqe8rTyMRSGwJgImQFSx hhWymCvKtvX/Igq1cfKQy1pUFIWEXwdfhF7aEUKOHTqBqVAwdE1fIEY6yR4oZ8rG3o3Ju23UQ bKh6ixqQheVifmbgwl07EWdxorvS1hpl02i/Zvj9CfuYzRTw7oDPAZ/74xb9R01Uvt98pSUKC QE2CSs4OkokS6/nWeSXJTdVBubNuPkDfQlD3bjngR6wfOcInv0CKIoSP1kq+khcoYQLg7ketk 1FTuqyhaRR6LnQHpYKWAWkSRamYGyjb7u38+XDLhcKAx823d0kHRs1Ppax2X/b1jQ9Re6CxUg 7OBadX7XKDwoXYRQt6z67uVjMP5qx1dct2a3AOoBzyxsUzYKXyoYzUY8I0k6rTpB8yV6QgnDL Rtr7AAsAKsvV0muw6X/SmK8yO6RsaQ9CbtliGvjQXRVf71EjPIsKwFgUZGODYWSUP/MlIqXAx 3mLCP4KZHu8yzjw+IragnUlyFgOOVLJlVpVT8xk3tqzzERfXpUMatCAWTNpLm8U7unz2ha4KK tpXM1kxBowFJ6cdxrw8wANxqSJhQpPAVs0O6u0hDVIdxOZxOc7kOvYx2QJlxRQBmY7Vs8ToOk nLHrWTLEwUQTHo9OZ75qcjqmv/y193D3KZQnbj8y0tPd8t0LhflcZaZgKndWp0HxeVMQOdcUP Vxrkuc0aIgM2HeLi0reBkU1UT7y6WnnQ682Umku2YfRQ3VdWUQ0HVKtoMFNuSbo8ZfmQOdQzk R8IgPYzaakCv2Ew8d3P0P0AYN0XwJlSDWDmlnealIKdet4+8xAZlpvVYedjD0fsJZlOMg/yJR 5L7kut0 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, 22 Apr 2017 14:17:46 +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 "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 16f14d4c3e85..5eaf946aeac6 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c @@ -1908,8 +1908,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,