From patchwork Sun Nov 8 14:17:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 7578381 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 34639C05C6 for ; Sun, 8 Nov 2015 14:27:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4493920615 for ; Sun, 8 Nov 2015 14:27:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 58FE420602 for ; Sun, 8 Nov 2015 14:27:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751834AbbKHO1s (ORCPT ); Sun, 8 Nov 2015 09:27:48 -0500 Received: from m50-135.163.com ([123.125.50.135]:52848 "EHLO m50-135.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751764AbbKHO1s (ORCPT ); Sun, 8 Nov 2015 09:27:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=dxn0TK/zOo6w3eD+AD iN8Ta8Vx+5Vg7RlGkJj0Q+Hhg=; b=k2tTeTCWkuB/2dhDS2tNtmdtaBIr9hZEC+ pE4LpQdZejgvCh1H/aR1sEu9Yy0pj0Qyh83GqVlGufZFY0e8VJk3stIZ4OVf3u0B /rL62uhXKqhj30xC2Uo++QAk6iDjzDdw1cbT6Gk+weVyubMlODaPITYBMI0C88b5 M/P8rTY0U= Received: from localhost (unknown [116.77.146.30]) by smtp5 (Coremail) with SMTP id D9GowABntpmbWT9WtTstAA--.19262S3; Sun, 08 Nov 2015 22:18:05 +0800 (CST) From: Geliang Tang To: Doug Ledford , Sean Hefty , Hal Rosenstock , Greg Kroah-Hartman , Mike Marciniszyn Cc: Geliang Tang , linux-rdma@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] staging: rdma: use kmalloc_array instead of kmalloc Date: Sun, 8 Nov 2015 22:17:52 +0800 Message-Id: <9c21d2635419867a29994568c2dfda0b72cce63d.1446991712.git.geliangtang@163.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <6ada2cca5a646c6bea9a900a48109d10cdc45e85.1446991712.git.geliangtang@163.com> References: <6ada2cca5a646c6bea9a900a48109d10cdc45e85.1446991712.git.geliangtang@163.com> In-Reply-To: <6ada2cca5a646c6bea9a900a48109d10cdc45e85.1446991712.git.geliangtang@163.com> References: <6ada2cca5a646c6bea9a900a48109d10cdc45e85.1446991712.git.geliangtang@163.com> X-CM-TRANSID: D9GowABntpmbWT9WtTstAA--.19262S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7uF1xKFy3KFWUCr1xtr17trb_yoW8tr18pF WrKr1DCr95Aw1Ygr1jyayIyF1rC3WfZFykW3y3Cw1Y9r1YkF1xAF9YgFyqqFZxuF93Ca4a qF1jg34UZF1UtrUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jV0PfUUUUU= X-Originating-IP: [116.77.146.30] X-CM-SenderInfo: 5jhoxtpqjwt0rj6rljoofrz/1tbiox2smVUL2jfUHAAAsw Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use kmalloc_array instead of kmalloc to allocate memory for an array. Signed-off-by: Geliang Tang --- drivers/staging/rdma/amso1100/c2.c | 6 ++++-- drivers/staging/rdma/ipath/ipath_file_ops.c | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rdma/amso1100/c2.c b/drivers/staging/rdma/amso1100/c2.c index 35ac536..4e6d24a 100644 --- a/drivers/staging/rdma/amso1100/c2.c +++ b/drivers/staging/rdma/amso1100/c2.c @@ -116,7 +116,8 @@ static int c2_tx_ring_alloc(struct c2_ring *tx_ring, void *vaddr, struct c2_element *elem; int i; - tx_ring->start = kmalloc(sizeof(*elem) * tx_ring->count, GFP_KERNEL); + tx_ring->start = kmalloc_array(tx_ring->count, sizeof(*elem), + GFP_KERNEL); if (!tx_ring->start) return -ENOMEM; @@ -165,7 +166,8 @@ static int c2_rx_ring_alloc(struct c2_ring *rx_ring, void *vaddr, struct c2_element *elem; int i; - rx_ring->start = kmalloc(sizeof(*elem) * rx_ring->count, GFP_KERNEL); + rx_ring->start = kmalloc_array(rx_ring->count, sizeof(*elem), + GFP_KERNEL); if (!rx_ring->start) return -ENOMEM; diff --git a/drivers/staging/rdma/ipath/ipath_file_ops.c b/drivers/staging/rdma/ipath/ipath_file_ops.c index 13c3cd1..6187b84 100644 --- a/drivers/staging/rdma/ipath/ipath_file_ops.c +++ b/drivers/staging/rdma/ipath/ipath_file_ops.c @@ -917,15 +917,15 @@ static int ipath_create_user_egr(struct ipath_portdata *pd) chunk = pd->port_rcvegrbuf_chunks; egrperchunk = pd->port_rcvegrbufs_perchunk; size = pd->port_rcvegrbuf_size; - pd->port_rcvegrbuf = kmalloc(chunk * sizeof(pd->port_rcvegrbuf[0]), - GFP_KERNEL); + pd->port_rcvegrbuf = kmalloc_array(chunk, sizeof(pd->port_rcvegrbuf[0]), + GFP_KERNEL); if (!pd->port_rcvegrbuf) { ret = -ENOMEM; goto bail; } pd->port_rcvegrbuf_phys = - kmalloc(chunk * sizeof(pd->port_rcvegrbuf_phys[0]), - GFP_KERNEL); + kmalloc_array(chunk, sizeof(pd->port_rcvegrbuf_phys[0]), + GFP_KERNEL); if (!pd->port_rcvegrbuf_phys) { ret = -ENOMEM; goto bail_rcvegrbuf;