[PATCH v3 09/10] ethdev: fix possible null pointer access

Chengwen Feng fengchengwen at huawei.com
Thu May 5 10:02:32 CEST 2022


The rte_tel_data_alloc() may return NULL, so the caller should add
judgement for it.

Fixes: 083b0b310b19 ("ethdev: add common stats for telemetry")
Cc: stable at dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen at huawei.com>
---
 lib/ethdev/rte_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 76037e635b..4a76272722 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -5485,6 +5485,8 @@ eth_dev_add_port_queue_stats(struct rte_tel_data *d, uint64_t *q_stats,
 {
 	int q;
 	struct rte_tel_data *q_data = rte_tel_data_alloc();
+	if (q_data == NULL)
+		return;
 	rte_tel_data_start_array(q_data, RTE_TEL_U64_VAL);
 	for (q = 0; q < RTE_ETHDEV_QUEUE_STAT_CNTRS; q++)
 		rte_tel_data_add_array_u64(q_data, q_stats[q]);
-- 
2.33.0



More information about the dev mailing list