From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 67F893B5 for ; Mon, 6 Feb 2017 18:33:11 +0100 (CET) Received: by mail-wm0-f66.google.com with SMTP id c85so23193082wmi.1 for ; Mon, 06 Feb 2017 09:33:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=miyTrXnMtC3S20khvApkV6I/HP8WwQHV/8c4BQMQkig=; b=GX2CkMTpnKs+JKmUjDTbWgnueS7OWaFKvFOcs9AWXpUrbhECWlwYzXChvQEre8PDY7 qpkwXSLNdYsu9IBRuiQE+/nUOC3kwZX3A1ewVhKufVEUn7CZ3DOvZREMU6oPD0FZD7/z lFuM/+yoclO9ZeoFcnzhF+t0iij4oAU/2RyyNbyBdNHD3Bnrw711L3++iMwo9KI8C0Vl aXXYB+yCacgZ7vooM+7q4Hd0AGbgPYZRn8ZJ8z4mzHMyc4zE0o4T6LjVL0alYW81QPt2 ngnGqxz/ZZ+gJV9q3ErRcv7Rl7tIiKugf8iRCDo17Gep2DC8wq3cqJva9I4kXPG0MHy8 S0FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=miyTrXnMtC3S20khvApkV6I/HP8WwQHV/8c4BQMQkig=; b=TEZwT2+xynOxlcdclkFmqKh+bz5Ax55mKaFCXS9lwi5J9aCEYHziSUshWpLpL7CIks rpMha3QLzcrM2NKbn+OnFnro+l5CevLWFrpf7ghRYrC5HAWSkpHku4X4I8PHaXPxHNpD fK9wG0fLcHL7UsQnLaiFRJHGus2bWhgM95gi5mYUiiyZVjI7r9gXf8cA4jr8ixKV9DI/ rJxnYmnGKFpDl7DzDh4FJ1gQZhAlkNJp+cEgnk2/U6bwG06ISGyEWaVMs5+orLKyXUEC J4dpnNSn3lMZgl4nuvcQWKVtIfcyy2LlWH1pHl/u2TLF7i7u7L6dhfWEpSerYOk9dVxs grXw== X-Gm-Message-State: AIkVDXLjYKW45CszXTJznYJ/TLi/LyX1QwVjhbAMwl2xW2y40KsjkrKBv/0g1EjoucX3lw== X-Received: by 10.223.147.100 with SMTP id 91mr10035859wro.5.1486402391078; Mon, 06 Feb 2017 09:33:11 -0800 (PST) Received: from weierstrass.local.net ([91.200.109.169]) by smtp.gmail.com with ESMTPSA id 186sm14012064wmw.24.2017.02.06.09.33.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Feb 2017 09:33:10 -0800 (PST) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Cc: h.mikita89@gmail.com, Alan Dewar Date: Mon, 6 Feb 2017 18:32:42 +0100 Message-Id: <1486402362-15098-1-git-send-email-jblunck@infradead.org> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] sched: fix segmentation fault when freeing port X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Feb 2017 17:33:11 -0000 From: Alan Dewar 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") Signed-off-by: Alan Dewar Signed-off-by: Jan Blunck --- 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 e6dace2..614705d 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.7.4