net/ena/base: fix unsafe memcpy on invalid memory
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")
Signed-off-by Shai Brandes <[email protected]>
Reviewed-by Amit Bernstein <[email protected]>
Reviewed-by Yosef Raisman <[email protected]>
--- drivers/net/ena/base/ena_com.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ena/base/ena_com.c +3 -3
@@ -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