diff mbox series

[1/2] thunderbolt: Fix buffers allocation for device without DisplayPort adaptors

Message ID 20220509204904.8936-2-gil.fine@intel.com
State New
Headers show
Series thunderbolt: Fix buffers allocation for device without DisplayPort adaptors | expand

Commit Message

Gil Fine May 9, 2022, 8:49 p.m. UTC
For the case of device without DP adaptors, we calculate incorrectly the
buffers allocation. Here we fix the calculation for this case.

Signed-off-by: Gil Fine <gil.fine@intel.com>
---
 drivers/thunderbolt/tunnel.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c
index 8ccd70920b6a..2c3cf7fc3357 100644
--- a/drivers/thunderbolt/tunnel.c
+++ b/drivers/thunderbolt/tunnel.c
@@ -102,8 +102,11 @@  static unsigned int tb_available_credits(const struct tb_port *port,
 		 * Maximum number of DP streams possible through the
 		 * lane adapter.
 		 */
-		ndp = (credits - (usb3 + pcie + spare)) /
-		      (sw->min_dp_aux_credits + sw->min_dp_main_credits);
+		if (sw->min_dp_aux_credits + sw->min_dp_main_credits)
+			ndp = (credits - (usb3 + pcie + spare)) /
+			      (sw->min_dp_aux_credits + sw->min_dp_main_credits);
+		else
+			ndp = 0;
 	} else {
 		ndp = 0;
 	}