Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2966631pxj; Mon, 17 May 2021 14:21:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOj/GxjQPjrjZK2zXQx6Kra0xM8JzzOAAYbjh6ZQ/Y6139reorjWUhX4sHf9Jh6r1Hkgel X-Received: by 2002:a05:6e02:1d18:: with SMTP id i24mr1401794ila.157.1621286461824; Mon, 17 May 2021 14:21:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621286461; cv=none; d=google.com; s=arc-20160816; b=IOUQxqpNV9Tb6jtHNRIdGydyNpsOLC294lHIuZ/5iKcYpNVSJ+BmNI7ExufgcV7Geq M9Cb56ZNOg9mdGr2Nxi3WL0KgY+08TNtmnHrve9SBocKpPZHFGWNmvgb8CURPzWY5Klj wp4vnLTNYHpbunL0jvJ5KiX/jQTJTwIOnbfdbqM1AGtF7Dd3UO4d1YW/3YcqzZnG+h3Q OwaJJXHX8vAOxUgeU+1D3NoIX6nsTL+bXkFdpvJ5BE2MlLTvjoTW3HKnG+Ws6cxFVIIO SCpyzG3fjlWGGU5tFCg4j0c+7nUIkhdQ43N/gQNoBUF1Shzy0dqZ/S9h216m+K/vz4/w 3aKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PZD0rCLt31iVcfUCJA/+DXFg+J3i95gRR2NqxeIbDRA=; b=b6VTo4cocrbxWiBO8bpuDAEYB//lmtVYFcjnGEUYt+/fm3B5GsC9uYsQP+5+umRscP RooNCdshqmbkQtuMCeGuAM2RTeWBn7n6FnFgWtPynNt9LmBsEcnjzww22ruAHfbwXohu bUURCmTe3KupaiqY4ByN8h8YEAInXpmZy1JVS8B/RQkqAPQZDWV+N5YjDvBsABY1d9R8 oB7UmpEvrY7Kyod9WnEf8lVfiiA44OhNA2P92I7af/9p3SimsWpzUrozz7lnhsL8nZQr BDya0POxozryDTMLJvLcOFofVRYhclFg7cjf47aWH/K0dqLV7Jm+PimVLJblGWEFrui3 hwPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L4tZd7iz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s4si21145858ilv.33.2021.05.17.14.20.47; Mon, 17 May 2021 14:21:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L4tZd7iz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237873AbhEQOKl (ORCPT + 99 others); Mon, 17 May 2021 10:10:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:58828 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238110AbhEQOH7 (ORCPT ); Mon, 17 May 2021 10:07:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AE96B6124C; Mon, 17 May 2021 14:06:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260383; bh=xCRDy6YwbgJQKS1kjq0Dn5Fl6sJjYPcS2H5tXuTZ7uo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L4tZd7iz3vP/YuKbekKZTDuGdNW3I4kvJwr82eribsVoj6FS2yrfvH0VWvB6h1jCN ZtpnKUV+Gx8ZZ00IKz0shITjGMcJZWS2nhuZvpb/GFH/ayatEghRZErOViWa2m7AuE vUXSFMa88HUefnCICIZCfrz1n2//3aaQlGYK0t8I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kaike Wan , Mike Marciniszyn , Dennis Dalessandro , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.12 055/363] IB/hfi1: Correct oversized ring allocation Date: Mon, 17 May 2021 15:58:41 +0200 Message-Id: <20210517140304.470421246@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Marciniszyn [ Upstream commit b536d4b2a279733f440c911dc831764690b90050 ] The completion ring for tx is using the wrong size to size the ring, oversizing the ring by two orders of magniture. Correct the allocation size and use kcalloc_node() to allocate the ring. Fix mistaken GFP defines in similar allocations. Link: https://lore.kernel.org/r/1617026056-50483-4-git-send-email-dennis.dalessandro@cornelisnetworks.com Reviewed-by: Kaike Wan Signed-off-by: Mike Marciniszyn Signed-off-by: Dennis Dalessandro Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/hfi1/ipoib.h | 3 ++- drivers/infiniband/hw/hfi1/ipoib_tx.c | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/ipoib.h b/drivers/infiniband/hw/hfi1/ipoib.h index f650cac9d424..d30c23b6527a 100644 --- a/drivers/infiniband/hw/hfi1/ipoib.h +++ b/drivers/infiniband/hw/hfi1/ipoib.h @@ -52,8 +52,9 @@ union hfi1_ipoib_flow { * @producer_lock: producer sync lock * @consumer_lock: consumer sync lock */ +struct ipoib_txreq; struct hfi1_ipoib_circ_buf { - void **items; + struct ipoib_txreq **items; unsigned long head; unsigned long tail; unsigned long max_items; diff --git a/drivers/infiniband/hw/hfi1/ipoib_tx.c b/drivers/infiniband/hw/hfi1/ipoib_tx.c index edd4eeac8dd1..cdc26ee3cf52 100644 --- a/drivers/infiniband/hw/hfi1/ipoib_tx.c +++ b/drivers/infiniband/hw/hfi1/ipoib_tx.c @@ -702,14 +702,14 @@ int hfi1_ipoib_txreq_init(struct hfi1_ipoib_dev_priv *priv) priv->tx_napis = kcalloc_node(dev->num_tx_queues, sizeof(struct napi_struct), - GFP_ATOMIC, + GFP_KERNEL, priv->dd->node); if (!priv->tx_napis) goto free_txreq_cache; priv->txqs = kcalloc_node(dev->num_tx_queues, sizeof(struct hfi1_ipoib_txq), - GFP_ATOMIC, + GFP_KERNEL, priv->dd->node); if (!priv->txqs) goto free_tx_napis; @@ -741,9 +741,9 @@ int hfi1_ipoib_txreq_init(struct hfi1_ipoib_dev_priv *priv) priv->dd->node); txq->tx_ring.items = - vzalloc_node(array_size(tx_ring_size, - sizeof(struct ipoib_txreq)), - priv->dd->node); + kcalloc_node(tx_ring_size, + sizeof(struct ipoib_txreq *), + GFP_KERNEL, priv->dd->node); if (!txq->tx_ring.items) goto free_txqs; @@ -764,7 +764,7 @@ free_txqs: struct hfi1_ipoib_txq *txq = &priv->txqs[i]; netif_napi_del(txq->napi); - vfree(txq->tx_ring.items); + kfree(txq->tx_ring.items); } kfree(priv->txqs); @@ -817,7 +817,7 @@ void hfi1_ipoib_txreq_deinit(struct hfi1_ipoib_dev_priv *priv) hfi1_ipoib_drain_tx_list(txq); netif_napi_del(txq->napi); (void)hfi1_ipoib_drain_tx_ring(txq, txq->tx_ring.max_items); - vfree(txq->tx_ring.items); + kfree(txq->tx_ring.items); } kfree(priv->txqs); -- 2.30.2