thunderbolt: Fix buffer allocation of devices with no DisplayPort adapters
authorGil Fine <gil.fine@intel.com>
Mon, 9 May 2022 20:49:03 +0000 (23:49 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Thu, 12 May 2022 06:22:11 +0000 (09:22 +0300)
For the case of a device without DisplayPort adapters we calculate
incorrectly the amount of buffers. Fix the calculation for this case.

Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/thunderbolt/tunnel.c

index 8ccd709..2c3cf7f 100644 (file)
@@ -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;
        }