Skip to content

Commit

Permalink
app/testpmd: fix segment fault with invalid queue ID
Browse files Browse the repository at this point in the history
When input queue ID is invalid, it will lead to
Segmentation fault, like:

dpdk-testpmd -a 0000:01:00.0 -- -i
testpmd> show port 0 txq/rxq 99 desc 0 status
Segmentation fault

dpdk-testpmd -a 0000:01:00.0 -- -i
testpmd> show port 0 rxq 99 desc used count
Segmentation fault

This patch fixes it.

Fixes: fae9aa7 ("app/testpmd: support checking descriptor status")
Fixes: 3f9acb5 ("ethdev: avoid non-dataplane checks in Rx queue count")
Cc: stable@dpdk.org

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
Dengdui Huang authored and ovsrobot committed May 25, 2023
1 parent eb91c77 commit f1bcde8
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions app/test-pmd/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -12275,12 +12275,13 @@ cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
int rc;

if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
return;
}

if (!strcmp(res->cmd_keyword, "rxq")) {
if (rte_eth_dev_rxq_avail(res->cmd_pid, res->cmd_qid) != 0) {
fprintf(stderr,
"Invalid input: port id = %d, queue id = %d\n",
res->cmd_pid, res->cmd_qid);
return;
}
rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
res->cmd_did);
if (rc < 0) {
Expand All @@ -12296,6 +12297,12 @@ cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
else
printf("Desc status = UNAVAILABLE\n");
} else if (!strcmp(res->cmd_keyword, "txq")) {
if (rte_eth_dev_txq_avail(res->cmd_pid, res->cmd_qid) != 0) {
fprintf(stderr,
"Invalid input: port id = %d, queue id = %d\n",
res->cmd_pid, res->cmd_qid);
return;
}
rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
res->cmd_did);
if (rc < 0) {
Expand Down Expand Up @@ -12375,8 +12382,10 @@ cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
int rc;

if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
if (rte_eth_dev_rxq_avail(res->cmd_pid, res->cmd_qid) != 0) {
fprintf(stderr,
"Invalid input: port id = %d, queue id = %d\n",
res->cmd_pid, res->cmd_qid);
return;
}

Expand Down

0 comments on commit f1bcde8

Please sign in to comment.