From: Jerin Jacob <jerinjacobk@gmail.com>
To: Ganapati Kundapura <ganapati.kundapura@intel.com>
Cc: dpdk-dev <dev@dpdk.org>,
"Jayatheerthan, Jay" <jay.jayatheerthan@intel.com>
Subject: Re: [dpdk-dev] [PATCH v4] eventdev/rx-adapter: fix segfault in queue conf get
Date: Wed, 6 Oct 2021 23:02:24 +0530 [thread overview]
Message-ID: <CALBAE1PnQXacz61ysuCV9Lpv80rCjBCA_MuTD_2-nTLPmzLz4g@mail.gmail.com> (raw)
In-Reply-To: <20211001053000.1063729-1-ganapati.kundapura@intel.com>
On Fri, Oct 1, 2021 at 11:00 AM Ganapati Kundapura
<ganapati.kundapura@intel.com> wrote:
>
> rte_event_eth_rx_adapter_queue_conf_get() segfaults if called
> without queue added to the Rx adapter.
>
> Added check to no queues in Rx adapter and error out on being
> called with no queue in Rx adapter.
>
> Added test case to call queue conf get without queues in
> Rx adapter.
>
> Fixes: b36879759b7f3ce ("eventdev/rx_adapter: support Rx queue config get")
Squashed to relevant patches to dpdk-next-net-eventdev/for-main. Thanks
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
>
> ---
> v4:
> * Fixed checkpatch warning
>
> v3:
> * Added fixes line
>
> v2:
> * Corrected typo in the comment
> ---
>
> diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
> index 13664a3..d0dc552 100644
> --- a/app/test/test_event_eth_rx_adapter.c
> +++ b/app/test/test_event_eth_rx_adapter.c
> @@ -751,20 +751,48 @@ static int
> adapter_queue_conf(void)
> {
> int err;
> - struct rte_event_eth_rx_adapter_queue_conf queue_conf;
> + struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
>
> - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
> + /* Case 1: queue conf get without any queues in Rx adapter */
> + err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> + TEST_ETHDEV_ID,
> + 0, &queue_conf);
> + TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> + /* Add queue to Rx adapter */
> + queue_conf.ev.queue_id = 0;
> + queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> + queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
> +
> + err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
> + TEST_ETHDEV_ID,
> + 0, &queue_conf);
> + TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> + /* Case 2: queue conf get with queue added to Rx adapter */
> + err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> + TEST_ETHDEV_ID,
> 0, &queue_conf);
> TEST_ASSERT(err == 0, "Expected 0 got %d", err);
>
> - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
> + /* Case 3: queue conf get with invalid rx queue id */
> + err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> + TEST_ETHDEV_ID,
> -1, &queue_conf);
> TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
>
> - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
> + /* Case 4: queue conf get with NULL queue conf struct */
> + err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> + TEST_ETHDEV_ID,
> 0, NULL);
> TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
>
> + /* Delete queue from the Rx adapter */
> + err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
> + TEST_ETHDEV_ID,
> + 0);
> + TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> return TEST_SUCCESS;
> }
>
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
> index 10491ca..2a84490 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> @@ -2844,12 +2844,13 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
> return -EINVAL;
>
> dev_info = &rx_adapter->eth_devices[eth_dev_id];
> - queue_info = &dev_info->rx_queue[rx_queue_id];
> - if (!queue_info->queue_enabled) {
> + if (dev_info->rx_queue == NULL ||
> + !dev_info->rx_queue[rx_queue_id].queue_enabled) {
> RTE_EDEV_LOG_ERR("Rx queue %u not added", rx_queue_id);
> return -EINVAL;
> }
>
> + queue_info = &dev_info->rx_queue[rx_queue_id];
> qi_ev = (struct rte_event *)&queue_info->event;
>
> memset(queue_conf, 0, sizeof(*queue_conf));
> --
> 2.6.4
>
prev parent reply other threads:[~2021-10-06 17:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-30 12:47 [dpdk-dev] [PATCH v1] eventdev/rx-adapter: " Ganapati Kundapura
2021-09-30 13:00 ` [dpdk-dev] [PATCH v2] " Ganapati Kundapura
2021-10-01 4:42 ` Naga Harish K, S V
2021-10-01 5:21 ` Kundapura, Ganapati
2021-10-01 5:19 ` [dpdk-dev] [PATCH v3] eventdev/rx-adapter: fix segfault in que " Ganapati Kundapura
2021-10-01 5:30 ` [dpdk-dev] [PATCH v4] eventdev/rx-adapter: fix segfault in queue " Ganapati Kundapura
2021-10-04 17:19 ` Jayatheerthan, Jay
2021-10-04 18:25 ` Kundapura, Ganapati
2021-10-05 8:19 ` Jayatheerthan, Jay
2021-10-06 17:32 ` Jerin Jacob [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CALBAE1PnQXacz61ysuCV9Lpv80rCjBCA_MuTD_2-nTLPmzLz4g@mail.gmail.com \
--to=jerinjacobk@gmail.com \
--cc=dev@dpdk.org \
--cc=ganapati.kundapura@intel.com \
--cc=jay.jayatheerthan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).