Skip to contentSkip to conversation

net/ena/base: fix unsafe memcpy on invalid memory

PATCH Superseded Shai Brandes 1 participant 1 message Oct 15, 2025 Network drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 18/21 net/ena/base: fix unsafe memcpy on invalid memory

The return status check was placed after a memcpy operation, which could result in copying from an invalid memory region if the feature fetch failed.

Fixes b68309be44c0 ("net/ena/base: update communication layer for the ENAv2")
---
 drivers/net/ena/base/ena_com.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ena/base/ena_com.c +3 -3
index b4437f532b..b003167bed 100644
@@ -2476,13 +2476,13 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
 	} else {
 		rc = ena_com_get_feature(ena_dev, &get_resp,
 					 ENA_ADMIN_MAX_QUEUES_NUM, 0);
+		if (rc)
+			return rc;
+
 		memcpy(&get_feat_ctx->max_queues, &get_resp.u.max_queue,
 		       sizeof(get_resp.u.max_queue));
 		ena_dev->tx_max_header_size =
 			get_resp.u.max_queue.max_header_size;
-
-		if (rc)
-			return rc;
 	}
 
 	rc = ena_com_get_feature(ena_dev, &get_resp,
Signature · 1 line
2.17.1