[PATCH v2 08/20] net/ena: add verification of DMA address width
Shai Brandes
shaibran at amazon.com
Wed Oct 15 14:08:51 CEST 2025
Fixed improper handling of error conditions when retrieving the
physical DMA address width from the device.
Currently, in case ena_com_get_dma_width() timeouts or retrieves invalid
value, it will go unnoticed and the flow will continue as usual using
error value as the dma width address.
Signed-off-by: Amit Bernstein <amitbern at amazon.com>
Signed-off-by: Shai Brandes <shaibran at amazon.com>
Reviewed-by: Yosef Raisman <yraisman at amazon.com>
---
drivers/net/ena/ena_ethdev.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index 568aca1152..5147a754b2 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -1948,7 +1948,7 @@ static int ena_device_init(struct ena_adapter *adapter,
{
struct ena_com_dev *ena_dev = &adapter->ena_dev;
uint32_t aenq_groups;
- int rc;
+ int dma_width, rc;
bool readless_supported;
/* Initialize mmio registers */
@@ -1978,7 +1978,12 @@ static int ena_device_init(struct ena_adapter *adapter,
goto err_mmio_read_less;
}
- ena_dev->dma_addr_bits = ena_com_get_dma_width(ena_dev);
+ dma_width = ena_com_get_dma_width(ena_dev);
+ if (unlikely(dma_width < 0)) {
+ PMD_DRV_LOG_LINE(ERR, "Invalid dma width value %d", dma_width);
+ rc = dma_width;
+ goto err_mmio_read_less;
+ }
/* ENA device administration layer init */
rc = ena_com_admin_init(ena_dev, &aenq_handlers);
--
2.17.1
More information about the dev
mailing list