From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D2161A0C47; Tue, 12 Oct 2021 09:36:33 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6115E40142; Tue, 12 Oct 2021 09:36:33 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id DC5DE4003C; Tue, 12 Oct 2021 09:36:31 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19C4UWbI024001; Tue, 12 Oct 2021 00:36:30 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=p3+3nlnivVh+a0yHMqiy7mI3D/+BOexVRU4Jy6flZAc=; b=OcLtTfgK9BjXwdyAEM4PrV91cqqU9N7L+//MJU8mg2iXx4ico1DNuyTVhZpmYLqg8t5j 04GS3vAVbu/NJd84GqHwpTUTnoLmvIGJdppXkB7XffqKtOx9B9Xk7LOKS60eFsFHBfim lbwvkCeHzCAwrwYxTHWrOddxtnjHfnVxnVdc2uk65VezHmZ0A+FU+KbwHwIfgJViwMJ8 DQ03N98TzC5qtiqMkSkMdNqsikoA5weYba6IhUOVng6WnPAWSlV/x9zfvsQnh/EJpBgp OAabX+xsplz4itQSKi52RFTrBMYLu1fQ7MXV6zRm/AZCBo9pPhqQW6StBu51c30axvGA HQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 3bn3d58ped-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 12 Oct 2021 00:36:30 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 12 Oct 2021 00:36:29 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Tue, 12 Oct 2021 00:36:29 -0700 Received: from localhost.localdomain (unknown [10.28.34.25]) by maili.marvell.com (Postfix) with ESMTP id E88E03F7089; Tue, 12 Oct 2021 00:36:27 -0700 (PDT) From: To: Xiaoyun Li CC: , Sunil Kumar Kori , Date: Tue, 12 Oct 2021 13:06:24 +0530 Message-ID: <20211012073624.399404-1-skori@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: uqP4RPstsUU4D6e6egLNSN0Y-5GdEULw X-Proofpoint-GUID: uqP4RPstsUU4D6e6egLNSN0Y-5GdEULw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-12_01,2021-10-11_01,2020-04-07_01 Subject: [dpdk-dev] [PATCH] app/testpmd: fix invalid memory access X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Sunil Kumar Kori During parsing of DSCP entries, memory is allocated and assgined to *dscp_table. Later on, same memory is accessed using *dscp_table[i++]. Due to higher precedence for array subscript, dscp_table[i++] will be executed first which actually does not point to the same memory which was allocated previously for DSCP table entries. Cc: stable@dpdk.org Fixes: e63b50162aa3 ("app/testpmd: clean metering and policing commands") Signed-off-by: Sunil Kumar Kori --- app/test-pmd/cmdline_mtr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c index b5dcfdadcf..ad7ef6ad98 100644 --- a/app/test-pmd/cmdline_mtr.c +++ b/app/test-pmd/cmdline_mtr.c @@ -101,13 +101,13 @@ parse_dscp_table_entries(char *str, enum rte_color **dscp_table) while (1) { if (strcmp(token, "G") == 0 || strcmp(token, "g") == 0) - *dscp_table[i++] = RTE_COLOR_GREEN; + (*dscp_table)[i++] = RTE_COLOR_GREEN; else if (strcmp(token, "Y") == 0 || strcmp(token, "y") == 0) - *dscp_table[i++] = RTE_COLOR_YELLOW; + (*dscp_table)[i++] = RTE_COLOR_YELLOW; else if (strcmp(token, "R") == 0 || strcmp(token, "r") == 0) - *dscp_table[i++] = RTE_COLOR_RED; + (*dscp_table)[i++] = RTE_COLOR_RED; else { free(*dscp_table); return -1; -- 2.25.1