net/cnxk: fix possible null dereference in telemetry

The return value of rte_tel_data_alloc() may be null pointer.
Add missing check vs null.

Fixes: 5ea354a1f2 ("net/cnxk: support telemetry")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
This commit is contained in:
Chengwen Feng 2022-05-13 10:53:57 +08:00 committed by Andrew Rybchenko
parent 590e988fdf
commit 67ead3fa8c

View File

@ -50,6 +50,8 @@ ethdev_tel_handle_info(const char *cmd __rte_unused,
rte_tel_data_add_dict_int(d, "n_ports", n_ports);
i_data = rte_tel_data_alloc();
if (i_data == NULL)
return -ENOMEM;
rte_tel_data_start_array(i_data, RTE_TEL_U64_VAL);
for (i = 0; i < RTE_MAX_ETHPORTS; i++) {