From 3b780b9e9e9221725abbad9820704d05d7d2805e Mon Sep 17 00:00:00 2001 From: Alan Dewar Date: Mon, 6 Feb 2017 18:32:42 +0100 Subject: [PATCH] sched: fix crash when freeing port Prevent a segmentation fault in rte_sched_port_free by only accessing the port structure after the NULL pointer check has been made. Fixes: 7b3c4f35 ("sched: fix releasing enqueued packets") Cc: stable@dpdk.org Signed-off-by: Alan Dewar Signed-off-by: Jan Blunck Acked-by: Cristian Dumitrescu --- lib/librte_sched/rte_sched.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index e6dace2f67..614705d81e 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -735,12 +735,14 @@ void rte_sched_port_free(struct rte_sched_port *port) { uint32_t qindex; - uint32_t n_queues_per_port = rte_sched_port_queues_per_port(port); + uint32_t n_queues_per_port; /* Check user parameters */ if (port == NULL) return; + n_queues_per_port = rte_sched_port_queues_per_port(port); + /* Free enqueued mbufs */ for (qindex = 0; qindex < n_queues_per_port; qindex++) { struct rte_mbuf **mbufs = rte_sched_port_qbase(port, qindex); -- 2.20.1