patches for DPDK stable branches
 help / color / mirror / Atom feed
From: <shaibran@amazon.com>
To: <ferruh.yigit@amd.com>, <bluca@debian.org>,
	<christian.ehrhardt@canonical.com>, <xuemingl@nvidia.com>,
	<ktraynor@redhat.com>
Cc: <stable@dpdk.org>, <dev@dpdk.org>, Shai Brandes <shaibran@amazon.com>
Subject: [PATCH v2 1/1] net/ena/base: fix metrics excessive memory consumption
Date: Thu, 28 Mar 2024 16:03:07 +0200	[thread overview]
Message-ID: <20240328140307.1291-2-shaibran@amazon.com> (raw)
In-Reply-To: <20240328140307.1291-1-shaibran@amazon.com>

From: Shai Brandes <shaibran@amazon.com>

The driver accidentally allocates a huge memory
buffer for the customer metrics because it uses
an uninitialized variable for the buffer length.
This can lead to excessive memory footprint for
the driver which can even fail to initialize in
case of insufficient memory.

Signed-off-by: Shai Brandes <shaibran@amazon.com>
Reviewed-by: Amit Bernstein <amitbern@amazon.com>
Fixes: f73f53f7dc7a ("net/ena: upgrade HAL")
Bugzilla ID: 1400
---
 drivers/net/ena/base/ena_com.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ena/base/ena_com.c b/drivers/net/ena/base/ena_com.c
index 6953a1fa33..8ae7dcf48e 100644
--- a/drivers/net/ena/base/ena_com.c
+++ b/drivers/net/ena/base/ena_com.c
@@ -3134,16 +3134,18 @@ int ena_com_allocate_debug_area(struct ena_com_dev *ena_dev,
 int ena_com_allocate_customer_metrics_buffer(struct ena_com_dev *ena_dev)
 {
 	struct ena_customer_metrics *customer_metrics = &ena_dev->customer_metrics;
+	customer_metrics->buffer_len = ENA_CUSTOMER_METRICS_BUFFER_SIZE;
+	customer_metrics->buffer_virt_addr = NULL;
 
 	ENA_MEM_ALLOC_COHERENT(ena_dev->dmadev,
 			       customer_metrics->buffer_len,
 			       customer_metrics->buffer_virt_addr,
 			       customer_metrics->buffer_dma_addr,
 			       customer_metrics->buffer_dma_handle);
-	if (unlikely(customer_metrics->buffer_virt_addr == NULL))
+	if (unlikely(customer_metrics->buffer_virt_addr == NULL)) {
+		customer_metrics->buffer_len = 0;
 		return ENA_COM_NO_MEM;
-
-	customer_metrics->buffer_len = ENA_CUSTOMER_METRICS_BUFFER_SIZE;
+	}
 
 	return 0;
 }
-- 
2.17.1


  reply	other threads:[~2024-03-28 14:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28 14:03 [PATCH v2 0/1] net/ena/base: bug fix for 23.11 stable only shaibran
2024-03-28 14:03 ` shaibran [this message]
2024-03-28 14:22 ` Brandes, Shai
2024-03-28 14:29   ` Luca Boccassi
2024-04-08 12:15 shaibran
2024-04-08 12:15 ` [PATCH v2 1/1] net/ena/base: fix metrics excessive memory consumption shaibran
2024-04-13  8:23   ` Xueming Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240328140307.1291-2-shaibran@amazon.com \
    --to=shaibran@amazon.com \
    --cc=bluca@debian.org \
    --cc=christian.ehrhardt@canonical.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=ktraynor@redhat.com \
    --cc=stable@dpdk.org \
    --cc=xuemingl@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).