[v3,10/10] net/cnxk: fix telemetry possible null pointer access

Message ID 20220505080233.12737-11-fengchengwen@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Andrew Rybchenko
Headers
Series bugfix for ethdev telemetry |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/intel-Testing success Testing PASS

Commit Message

fengchengwen May 5, 2022, 8:02 a.m. UTC
  The return value of rte_tel_data_alloc() may be null pointer, in this
patch, the null check function is added.

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

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 drivers/net/cnxk/cnxk_ethdev_telemetry.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Andrew Rybchenko May 12, 2022, 10:30 a.m. UTC | #1
On 5/5/22 11:02, Chengwen Feng wrote:
> The return value of rte_tel_data_alloc() may be null pointer, in this
> patch, the null check function is added.
> 
> Fixes: 5ea354a1f2cc ("net/cnxk: support telemetry")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>

Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
  

Patch

diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
index 83bc65848c..4fd9048643 100644
--- a/drivers/net/cnxk/cnxk_ethdev_telemetry.c
+++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
@@ -49,6 +49,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++) {