DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1] eventdev/rx-adapter: segfault in queue conf get
@ 2021-09-30 12:47 Ganapati Kundapura
  2021-09-30 13:00 ` [dpdk-dev] [PATCH v2] " Ganapati Kundapura
  0 siblings, 1 reply; 10+ messages in thread
From: Ganapati Kundapura @ 2021-09-30 12:47 UTC (permalink / raw)
  To: jerinjacobk, dev; +Cc: jay.jayatheerthan

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.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index 13664a3..76ce57b 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 invalue 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-10-06 17:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 12:47 [dpdk-dev] [PATCH v1] eventdev/rx-adapter: segfault in queue conf get 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 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).