From patchwork Wed Feb 8 21:20:42 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: 9563451 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 C8C40601C3 for ; Wed, 8 Feb 2017 21:21:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 225D8284D8 for ; Wed, 8 Feb 2017 21:21:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 172F1284FF; Wed, 8 Feb 2017 21:21:38 +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 C52D5284D8 for ; Wed, 8 Feb 2017 21:21:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751317AbdBHVVX (ORCPT ); Wed, 8 Feb 2017 16:21:23 -0500 Received: from mout.web.de ([212.227.15.14]:50750 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751405AbdBHVU5 (ORCPT ); Wed, 8 Feb 2017 16:20:57 -0500 Received: from [192.168.1.2] ([77.181.90.255]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Lr2Yd-1bx1n53bTH-00edED; Wed, 08 Feb 2017 22:20:44 +0100 Subject: [PATCH 10/14] RDMA/cxgb4: Use kmalloc_array() in c4iw_id_table_alloc() To: linux-rdma@vger.kernel.org, Doug Ledford , Hal Rosenstock , Sean Hefty , Steve Wise References: <0aff92fa-2891-333a-2e1e-ca309db2ec72@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: Date: Wed, 8 Feb 2017 22:20:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <0aff92fa-2891-333a-2e1e-ca309db2ec72@users.sourceforge.net> X-Provags-ID: V03:K0:ECKvT7CqOQa8OhA6/fym3+T0Pu//ikUjDumRxSjDFuCpJsvehlV WjDlkiE4GOAa3pWndQgVrKrcUMwSNeY48kl5JqjEuT4J8gYQ0Nw611wi0qfgGm6nQdCgIRk CfgL7hpD+k+LRFK5bE/ZYYkDyw+05rRvxrwZGZviXuNSSw76UFtPKycJ5x/b2PA+oPVlv6r L+SPt3MkVj6zK5Vc8Qurg== X-UI-Out-Filterresults: notjunk:1; V01:K0:xrnVm124Beo=:G48e4Luc+5MGdjraFHWOJA UCPPKhjiPjS/GVRv6lLJUv/mSMvKXhv31SMx8nH9+fjLU6B7FEyNH1JYJpxwyGs2izKOUKrmP trx4Te9qcp5zA+EMAgRSvJwItsE8NgXSbci2m83PNfe3UlTs5CsOOQFGE/5IL1etBid9DmEbV TODlJoUCOTw2NvZYZCNWT8UUH/Sa0Oh7iDOF2vtDQiBhIDxHsZ6uobwAlTWWgMLn5B72VQGMH FJnzcW6cfWXffsRHejOE5q6ceFUW15oCeeJlSzAV7y24YxV7seoUP4+XX0LxbU7+wRSiz/207 ncCbQeoUqIywrAZjEnoogXAcQDjKHwYUQJaxrCFLObxBxF1pS/qObOf/y+wQnCSFZZc7DQiiU dNLvNZGpiE8CpTNwFkqC9zkwValmBLzgoOPRBuCXapYKzN7JXhKruYBK7vzpOrnDtmS86lzHd o0/VxVjWLNjPbO2YZ9rwN7I9E7X9gcYzuyReXAsOHkkVDikNPkSnRPrLpH1epSOOqJcIANnMv FDP/Mh7YfQ/SNMCOf4lxWmUI8ZRdNSSP9zX3/BRmt/GkOJhZcj7nbSg+NWegEjkvIkBOijYKy SONkPjvARy6NI8sYbkgj84pERk7TCk1CB1RBSeyeTy/SF1LEz57pu4cuQ7SCLNCyrtSAGfbXS QZY5d2NZoC9P3IDCTLzy1m2+O6jET+y5TDAT0/Bthsgy5sSeQlJxfhFBHJIhWqEYwAFN/6wx5 lnBuPbjlDT8hOJjKkDDtss55KbJMOF5z4crKKOaGLCf1bqdtjDSunygiXFyVqT4dUXNcE8VjP 0CH4Ho2 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 Feb 2017 20:03:24 +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/cxgb4/id_table.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/cxgb4/id_table.c b/drivers/infiniband/hw/cxgb4/id_table.c index 0161ae6ad629..51a0b7244e35 100644 --- a/drivers/infiniband/hw/cxgb4/id_table.c +++ b/drivers/infiniband/hw/cxgb4/id_table.c @@ -93,8 +93,9 @@ int c4iw_id_table_alloc(struct c4iw_id_table *alloc, u32 start, u32 num, alloc->last = 0; alloc->max = num; spin_lock_init(&alloc->lock); - alloc->table = kmalloc(BITS_TO_LONGS(num) * sizeof(long), - GFP_KERNEL); + alloc->table = kmalloc_array(BITS_TO_LONGS(num), + sizeof(*alloc->table), + GFP_KERNEL); if (!alloc->table) return -ENOMEM;