diff mbox series

[v4,8/9] ethdev: fix possible null pointer access

Message ID 20220513025357.52275-9-fengchengwen@huawei.com (mailing list archive)
State New
Delegated to: Andrew Rybchenko
Headers show
Series bugfix for ethdev telemetry | expand


Context Check Description
ci/checkpatch success coding style OK

Commit Message

fengchengwen May 13, 2022, 2:53 a.m. UTC
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@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
 lib/ethdev/rte_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series


diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 1ae686a7aa..60c4361256 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -5487,6 +5487,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]);