From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sagi Grimberg Subject: [PATCH] net/mlx5: Fix possible NULL deref in RX path Date: Mon, 1 Aug 2016 11:44:21 +0300 Message-ID: <1470041061-8059-1-git-send-email-sagi@grimberg.me> To: dev@dpdk.org Return-path: Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by dpdk.org (Postfix) with ESMTP id 99B3F2C0C for ; Mon, 1 Aug 2016 10:44:25 +0200 (CEST) Received: from bzq-82-81-101-184.red.bezeqint.net ([82.81.101.184] helo=bombadil.infradead.org) by merlin.infradead.org with esmtpsa (Exim 4.85_2 #1 (Red Hat Linux)) id 1bU8pk-00089b-B4 for dev@dpdk.org; Mon, 01 Aug 2016 08:44:24 +0000 List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The user is allowed to call ->rx_pkt_burst() even without free mbufs in the pool. In this scenario we'll fail allocating a rep mbuf on the first iteration (where pkt is still NULL). This would cause us to deref a NULL pkt (reset refcount and free). Fix this by checking the pkt before freeing it. Signed-off-by: Sagi Grimberg --- drivers/net/mlx5/mlx5_rxtx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index fce3381ae87a..a07cc4794023 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -1572,7 +1572,7 @@ mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) rte_prefetch0(wqe); rep = rte_mbuf_raw_alloc(rxq->mp); if (unlikely(rep == NULL)) { - while (pkt != seg) { + while (pkt && pkt != seg) { assert(pkt != (*rxq->elts)[idx]); seg = NEXT(pkt); rte_mbuf_refcnt_set(pkt, 0); -- 1.9.1