From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 21CF2A00C4;
	Thu,  5 May 2022 10:09:28 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 5D0AE4285C;
	Thu,  5 May 2022 10:08:41 +0200 (CEST)
Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187])
 by mails.dpdk.org (Postfix) with ESMTP id 27A7940E0F
 for <dev@dpdk.org>; Thu,  5 May 2022 10:08:32 +0200 (CEST)
Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.57])
 by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Kv5t06QXMzhYhK;
 Thu,  5 May 2022 16:08:08 +0800 (CST)
Received: from localhost.localdomain (10.67.165.24) by
 dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2375.24; Thu, 5 May 2022 16:08:30 +0800
From: Chengwen Feng <fengchengwen@huawei.com>
To: <thomas@monjalon.net>, <ferruh.yigit@xilinx.com>,
 <andrew.rybchenko@oktetlabs.ru>, <ndabilpuram@marvell.com>,
 <kirankumark@marvell.com>, <skori@marvell.com>, <skoteshwar@marvell.com>
CC: <mb@smartsharesystems.com>, <stephen@networkplumber.org>, <dev@dpdk.org>
Subject: [PATCH v3 10/10] net/cnxk: fix telemetry possible null pointer access
Date: Thu, 5 May 2022 16:02:33 +0800
Message-ID: <20220505080233.12737-11-fengchengwen@huawei.com>
X-Mailer: git-send-email 2.33.0
In-Reply-To: <20220505080233.12737-1-fengchengwen@huawei.com>
References: <20220416010747.40714-1-fengchengwen@huawei.com>
 <20220505080233.12737-1-fengchengwen@huawei.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [10.67.165.24]
X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To
 dggpeml500024.china.huawei.com (7.185.36.10)
X-CFilter-Loop: Reflected
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

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(+)

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++) {
-- 
2.33.0