From patchwork Sat Jun 13 16:26:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11602873 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 53038138C for ; Sat, 13 Jun 2020 16:27:25 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 394AB2078A for ; Sat, 13 Jun 2020 16:27:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 394AB2078A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 074E421C986; Sat, 13 Jun 2020 09:27:24 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 5A16521C90F for ; Sat, 13 Jun 2020 09:27:22 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 80EBA240; Sat, 13 Jun 2020 12:27:19 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 785042A4; Sat, 13 Jun 2020 12:27:19 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Sat, 13 Jun 2020 12:26:57 -0400 Message-Id: <1592065636-28333-2-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1592065636-28333-1-git-send-email-jsimmons@infradead.org> References: <1592065636-28333-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 01/20] lnet: fix kmalloc size in config.c X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: NeilBrown sizeof(net->net_cpts) should be sizeof(*net->net_cpts). For consistency, also change a sizeof(ni->ni_cpts[0]) to sizeof(*ni->ni_cpts). and when allocating 'array' use sizeof(*array), not sizeof(*net->net_cpts); Fixes: 47db2bfba415 ("lnet: add list of cpts to lnet_net.") Reviewed-by: James Simmons Signed-off-by: NeilBrown --- net/lnet/lnet/config.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/lnet/lnet/config.c b/net/lnet/lnet/config.c index 3fc0298..9f36c82 100644 --- a/net/lnet/lnet/config.c +++ b/net/lnet/lnet/config.c @@ -171,7 +171,7 @@ struct lnet_text_buf { /* tmp struct for parsing routes */ } if (!net->net_cpts) { - net->net_cpts = kmalloc_array(ncpts, sizeof(net->net_cpts), + net->net_cpts = kmalloc_array(ncpts, sizeof(*net->net_cpts), GFP_KERNEL); if (!net->net_cpts) return -ENOMEM; @@ -197,7 +197,7 @@ struct lnet_text_buf { /* tmp struct for parsing routes */ u32 *array = NULL, *loc; u32 total_entries = j + net->net_ncpts; - array = kmalloc_array(total_entries, sizeof(*net->net_cpts), + array = kmalloc_array(total_entries, sizeof(*array), GFP_KERNEL); if (!array) { rc = -ENOMEM; @@ -545,7 +545,7 @@ struct lnet_ni * } else { size_t array_size = ncpts * sizeof(ni->ni_cpts[0]); - ni->ni_cpts = kmalloc_array(ncpts, sizeof(ni->ni_cpts[0]), + ni->ni_cpts = kmalloc_array(ncpts, sizeof(*ni->ni_cpts), GFP_KERNEL); if (!ni->ni_cpts) goto failed;