Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756703AbdDGVHJ (ORCPT ); Fri, 7 Apr 2017 17:07:09 -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 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-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1338 Lines: 34 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 --- 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; -- 2.12.2