From patchwork Fri Apr 7 21:06:25 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: 9670429 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 2C766602B3 for ; Fri, 7 Apr 2017 21:07:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E77A1FF8E for ; Fri, 7 Apr 2017 21:07:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1256826E56; Fri, 7 Apr 2017 21:07:04 +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 A5A5D1FF8E for ; Fri, 7 Apr 2017 21:07:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756528AbdDGVHC (ORCPT ); Fri, 7 Apr 2017 17:07:02 -0400 Received: from mout.web.de ([212.227.17.11]:54184 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756638AbdDGVGu (ORCPT ); Fri, 7 Apr 2017 17:06:50 -0400 Received: from [192.168.1.2] ([77.181.117.94]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MUFGo-1cVXl80jFC-00Qzmu; Fri, 07 Apr 2017 23:06:28 +0200 Subject: [PATCH 6/9] IB/iser: Use kmalloc_array() in iser_alloc_rx_descriptors() From: SF Markus Elfring To: linux-rdma@vger.kernel.org, target-devel@vger.kernel.org, David Ahern , Doug Ledford , Erez Shitrit , Feras Daoud , Hal Rosenstock , Leon Romanovsky , Mark Bloch , Or Gerlitz , Paolo Abeni , Roi Dayan , Sagi Grimberg , Sean Hefty , Yuval Shaia , Zhu Yanjun Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: <75e5726b-d75f-1b79-1242-08f6440e1691@users.sourceforge.net> Date: Fri, 7 Apr 2017 23:06:25 +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: Content-Language: en-GB X-Provags-ID: V03:K0:CgSwa737jSHfqosWg7jY4WWRneFnxO9tWME5REMZBiUq6026xdB PWX486zEa4WlD4iGpEDHhH7qJY4V+Fxz5knVO3VonNiRZ9EVeC4xwE9kdGTVjNK+hNDVVIa rTIOTeyy7qN7BJqccXj8jrU6YYlu5f9j9XwMxhK5/6X3jtGAjYzlaHSYL8u9WHUbXVQVNmX 8l4/q1HWXG/fn9qXXB2UQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:4Us5CBDihbg=:HrchMdqjX8BU2hrSbE2QHP jHnMq5aYq7YJrjgNpH9DVT8fK9yWsnYfVKyBPNC984oY0bEQK1gAteM8mWHWyATYgYcmd+fdr RvYWRS61NwEp2gAdgOr7763nePfYAvEAne0ku5gXGLat936+bIMWhfuYYYmBd3KlJxFIYROlN bbXW2jChv6ZvCZIaHA7xmHyUsDuEbi0He2kisv5wLmL01sZhvloUXttB63jhTOWKW/j8IEuI5 aBV0Qfad/g9epHKThB5wj+iLC2u5gKvl0esFyOFyzZW9lCD7s4M73G4oC3sTKhZzVCQEZ6VRL ZZxsKsdxMSSY9j91aPPnGFqxIuShu7ETHRJ6fJIPq6eKQq4JKbxP/QdrdM20pNsIS6VO+jJit H2GuvnJuL/RyHcacig2QliUtY3ZtCcS3qzWauN833xk5fBq1hkFUaVQBST/G3igax8MAY8BXy rqEZ50lqjPVvipqjxUy5+yr7abREaZydXppK6tRxCOl5kCPEm+IOad3xJFZWPiD0+W9tbQYuL A+igzoo8Ft6nougylsIERkEhUGwGaB1SodnuIxCEu7+IPvJsAetdDc13kwYFvN9zYglGDOl1I s7k/2xOghL2rxEbnRVzLPuYc3ltPFG/MALQ4gjnK9xEVxvLH1hPC5sFnDF50iGp0hq5Ta4rrB jbSRDTIaoLA28MoAGtC/3vVazH02zhRbg1yQYe/cKb5e326s4Ld0kYdDseviB3eh4ia4YoAdb k5MB07pbt8n//i7Rt25KAdra8R1R13A+ibLmPEEZUiFQlWPU0f1zKMacKAXk4FVmMUkBiBfPQ zcdMr1L 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, 7 Apr 2017 21:23:29 +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". * 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 Acked-by: Sagi Grimberg --- drivers/infiniband/ulp/iser/iser_initiator.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c index 81ae2e30dd12..6c48bdc8a64d 100644 --- a/drivers/infiniband/ulp/iser/iser_initiator.c +++ b/drivers/infiniband/ulp/iser/iser_initiator.c @@ -257,8 +257,9 @@ int iser_alloc_rx_descriptors(struct iser_conn *iser_conn, goto alloc_login_buf_fail; iser_conn->num_rx_descs = session->cmds_max; - iser_conn->rx_descs = kmalloc(iser_conn->num_rx_descs * - sizeof(struct iser_rx_desc), GFP_KERNEL); + iser_conn->rx_descs = kmalloc_array(iser_conn->num_rx_descs, + sizeof(*iser_conn->rx_descs), + GFP_KERNEL); if (!iser_conn->rx_descs) goto rx_desc_alloc_fail;