app/testpmd: fix the sample RSS issue

Message ID 1611632982-415500-1-git-send-email-jiaweiw@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series app/testpmd: fix the sample RSS issue |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-mellanox-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-testing warning Testing issues

Commit Message

Jiawei Wang Jan. 26, 2021, 3:49 a.m. UTC
  When the RSS with null key was set in sample actions list, it
caused the segmentation fault since the RSS key pointer was
NULL while did the memory copy.

This patch adds the RSS key NULL pointer checking before copying
to fix the segmentation fault issue.

Fixes: 11b1b0eddade ("app/testpmd: support RSS in sample action")

Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 app/test-pmd/cmdline_flow.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Ferruh Yigit Jan. 28, 2021, 10:32 p.m. UTC | #1
On 1/26/2021 3:49 AM, Jiawei Wang wrote:
> When the RSS with null key was set in sample actions list, it
> caused the segmentation fault since the RSS key pointer was
> NULL while did the memory copy.
> 
> This patch adds the RSS key NULL pointer checking before copying
> to fix the segmentation fault issue.
> 
> Fixes: 11b1b0eddade ("app/testpmd: support RSS in sample action")
> 
> Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/main, thanks.
  

Patch

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 0618611..64c0e0f 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -7885,7 +7885,7 @@  static int comp_set_modify_field_id(struct context *, const struct token *,
 			rss = action->conf;
 			rte_memcpy(&sample_rss_data[idx].conf,
 				   (const void *)rss, size);
-			if (rss->key_len) {
+			if (rss->key_len && rss->key) {
 				sample_rss_data[idx].conf.key =
 						sample_rss_data[idx].key;
 				rte_memcpy((void *)((uintptr_t)
@@ -7893,7 +7893,7 @@  static int comp_set_modify_field_id(struct context *, const struct token *,
 					   (const void *)rss->key,
 					   sizeof(uint8_t) * rss->key_len);
 			}
-			if (rss->queue_num) {
+			if (rss->queue_num && rss->queue) {
 				sample_rss_data[idx].conf.queue =
 						sample_rss_data[idx].queue;
 				rte_memcpy((void *)((uintptr_t)