Skip to content

Commit

Permalink
net/ena/base: fix metrics excessive memory consumption
Browse files Browse the repository at this point in the history
[ upstream commit c8a1898 ]

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.

Bugzilla ID: 1400
Fixes: f73f53f ("net/ena: upgrade HAL")
Cc: [email protected]

Signed-off-by: Shai Brandes <[email protected]>
Reviewed-by: Amit Bernstein <[email protected]>
  • Loading branch information
shaibran authored and steevenlee committed Apr 13, 2024
1 parent a20a3c1 commit cfa8a4c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/net/ena/base/ena_com.c
Original file line number Diff line number Diff line change
Expand Up @@ -3141,16 +3141,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;
}
Expand Down

0 comments on commit cfa8a4c

Please sign in to comment.