app/testpmd: fix sample action for RSS with no key

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: 11b1b0edda ("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>
This commit is contained in:
Jiawei Wang 2021-01-26 05:49:42 +02:00 committed by Ferruh Yigit
parent 4e719bd52d
commit b665487e0b

View File

@ -7888,7 +7888,7 @@ cmd_set_raw_parsed_sample(const struct buffer *in)
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)
@ -7896,7 +7896,7 @@ cmd_set_raw_parsed_sample(const struct buffer *in)
(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)