Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 May 2019 10:41:44 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r347277 - head/sys/dev/mlx5/mlx5_en
Message-ID:  <201905081041.x48AfiGq046910@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Wed May  8 10:41:44 2019
New Revision: 347277
URL: https://svnweb.freebsd.org/changeset/base/347277

Log:
  Avoid leaking send queue mbufs during error recovery in mlx5en(4).
  
  MFC after:	3 days
  Sponsored by:	Mellanox Technologies

Modified:
  head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
  head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c

Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==============================================================================
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c	Wed May  8 10:41:21 2019	(r347276)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c	Wed May  8 10:41:44 2019	(r347277)
@@ -1147,8 +1147,13 @@ mlx5e_free_sq_db(struct mlx5e_sq *sq)
 	int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
 	int x;
 
-	for (x = 0; x != wq_sz; x++)
+	for (x = 0; x != wq_sz; x++) {
+		if (sq->mbuf[x].mbuf != NULL) {
+			bus_dmamap_unload(sq->dma_tag, sq->mbuf[x].dma_map);
+			m_freem(sq->mbuf[x].mbuf);
+		}
 		bus_dmamap_destroy(sq->dma_tag, sq->mbuf[x].dma_map);
+	}
 	free(sq->mbuf, M_MLX5EN);
 }
 

Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
==============================================================================
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c	Wed May  8 10:41:21 2019	(r347276)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c	Wed May  8 10:41:44 2019	(r347277)
@@ -537,7 +537,7 @@ mlx5e_poll_tx_cq(struct mlx5e_sq *sq, int budget)
 		for (x = 0; x != sq->cev_factor; x++) {
 			ci = sqcc & sq->wq.sz_m1;
 			mb = sq->mbuf[ci].mbuf;
-			sq->mbuf[ci].mbuf = NULL;	/* Safety clear */
+			sq->mbuf[ci].mbuf = NULL;
 
 			if (mb == NULL) {
 				if (sq->mbuf[ci].num_bytes == 0) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905081041.x48AfiGq046910>