app/testpmd: fix crash

Message ID 20190614171939.94095-1-ferruh.yigit@intel.com (mailing list archive)
State Accepted, archived
Headers
Series app/testpmd: fix crash |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/intel-Performance-Testing fail Performance Testing issues
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/Intel-compilation fail apply issues

Commit Message

Ferruh Yigit June 14, 2019, 5:19 p.m. UTC
  Testpmd tries to calculate mbuf size based on "max Rx packet size" and
"max MTU segment number".
When driver set a "nb_mtu_seg_max" to zero, it causes division by zero
segmentation fault in testpmd.

If the PMD set "nb_mtu_seg_max" to zero, testpmd shouldn't try to
calculate the mbuf size.

Fixes: 33f9630fc23d ("app/testpmd: create mbuf based on max supported segments")

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
Cc: Sunil Kumar Kori <skori@marvell.com>
Cc: YufengX Mo <yufengx.mo@intel.com>
---
 app/test-pmd/testpmd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon June 16, 2019, 9:58 a.m. UTC | #1
14/06/2019 20:19, Ferruh Yigit:
> Testpmd tries to calculate mbuf size based on "max Rx packet size" and
> "max MTU segment number".
> When driver set a "nb_mtu_seg_max" to zero, it causes division by zero
> segmentation fault in testpmd.
> 
> If the PMD set "nb_mtu_seg_max" to zero, testpmd shouldn't try to
> calculate the mbuf size.
> 
> Fixes: 33f9630fc23d ("app/testpmd: create mbuf based on max supported segments")
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied, thanks
  

Patch

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 0f2fffec3..4e958bc44 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1174,7 +1174,8 @@  init_config(void)
 		/* Check for maximum number of segments per MTU. Accordingly
 		 * update the mbuf data size.
 		 */
-		if (port->dev_info.rx_desc_lim.nb_mtu_seg_max != UINT16_MAX) {
+		if (port->dev_info.rx_desc_lim.nb_mtu_seg_max != UINT16_MAX &&
+				port->dev_info.rx_desc_lim.nb_mtu_seg_max != 0) {
 			data_size = rx_mode.max_rx_pkt_len /
 				port->dev_info.rx_desc_lim.nb_mtu_seg_max;