Skip to content

Commit

Permalink
sol: avoid segmentation fault at boot time
Browse files Browse the repository at this point in the history
req_queue_init() fails when the link speed of the back interface
is not available _and_ the parameter req_channel_bw_mbps is not
defined.  When this happens, sol_stage2() calls cleanup_sol(),
which triggers a segmentation fault if a request queue is not
initiated.

This commit solves this problem by adding list_initiated() to
include/list.h, and using it to test if the request queues are
initiated in cleanup_sol() before freeing the associated resources.
  • Loading branch information
AltraMayor committed May 8, 2024
1 parent de9532c commit b9f7536
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
6 changes: 6 additions & 0 deletions include/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ INIT_LIST_HEAD(struct list_head *list)
list->prev = list;
}

static inline int
list_initiated(const struct list_head *head)
{
return head->next != NULL && head->prev != NULL;
}

/**
* list_entry - get the struct for this entry
* @ptr: the &struct list_head pointer.
Expand Down
28 changes: 18 additions & 10 deletions sol/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,23 +507,31 @@ cleanup_sol(struct sol_config *sol_conf)
goto free_sol_conf;

for (i = 0; i < sol_conf->num_lcores; i++) {
struct req_queue *req_queue = &sol_conf->instances[i].req_queue;
struct sol_instance *inst = &sol_conf->instances[i];
struct req_queue *req_queue = &inst->req_queue;
struct rte_mbuf *entry, *next;

list_for_each_entry_safe_m(entry, next, &req_queue->head) {
list_del(mbuf_to_list(entry));
rte_pktmbuf_free(entry);
req_queue->len--;
if (list_initiated(&req_queue->head)) {
list_for_each_entry_safe_m(entry, next,
&req_queue->head) {
list_del(mbuf_to_list(entry));
rte_pktmbuf_free(entry);
req_queue->len--;
}

if (unlikely(req_queue->len > 0)) {
G_LOG(CRIT, "%s(): bug: removing all requests from the priority queue on cleanup leaves the queue length at %"PRIu32" at lcore %u\n",
__func__, req_queue->len,
sol_conf->lcores[i]);
}
}

if (req_queue->len > 0)
G_LOG(NOTICE, "Bug: removing all requests from the priority queue on cleanup leaves the queue length at %"PRIu32" at lcore %u\n",
req_queue->len, sol_conf->lcores[i]);

rte_ring_free(sol_conf->instances[i].ring);
rte_ring_free(inst->ring);
inst->ring = NULL;
}

rte_free(sol_conf->instances);
sol_conf->instances = NULL;

free_sol_conf:
rte_free(sol_conf);
Expand Down

0 comments on commit b9f7536

Please sign in to comment.