dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/mlx5: Fix possible NULL deref in RX path
@ 2016-08-01  8:44 Sagi Grimberg
  2016-08-01 16:43 ` Adrien Mazarguil
  0 siblings, 1 reply; 6+ messages in thread
From: Sagi Grimberg @ 2016-08-01  8:44 UTC (permalink / raw)
  To: 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 <sagi@grimberg.me>
---
 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

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

end of thread, other threads:[~2016-08-02 11:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-01  8:44 [PATCH] net/mlx5: Fix possible NULL deref in RX path Sagi Grimberg
2016-08-01 16:43 ` Adrien Mazarguil
2016-08-02  9:31   ` Sagi Grimberg
2016-08-02  9:58     ` Adrien Mazarguil
2016-08-02 10:47       ` Sagi Grimberg
2016-08-02 11:31         ` Adrien Mazarguil

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).