diff options
author | Mika Westerberg <mika.westerberg@linux.intel.com> | 2021-11-18 09:06:45 +0200 |
---|---|---|
committer | Mika Westerberg <mika.westerberg@linux.intel.com> | 2021-12-07 15:18:33 +0300 |
commit | 6cb27a04fb779717c4a3d20233b93596885838cf (patch) | |
tree | e8394e37239e678d31d726aebd2860d39019f2ac /drivers/thunderbolt | |
parent | 1e56c88adecc2dfe14973fa47898861a839e62d4 (diff) | |
download | linux-stable-6cb27a04fb779717c4a3d20233b93596885838cf.tar.gz linux-stable-6cb27a04fb779717c4a3d20233b93596885838cf.tar.bz2 linux-stable-6cb27a04fb779717c4a3d20233b93596885838cf.zip |
thunderbolt: Do not allow subtracting more NFC credits than configured
This might happen if the boot firmware uses different amount of NFC
credits than what the router suggests, or we are dealing with pre-USB4
device.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Diffstat (limited to 'drivers/thunderbolt')
-rw-r--r-- | drivers/thunderbolt/switch.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index 3014146081c1..463cfdc0b42f 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -623,6 +623,9 @@ int tb_port_add_nfc_credits(struct tb_port *port, int credits) return 0; nfc_credits = port->config.nfc_credits & ADP_CS_4_NFC_BUFFERS_MASK; + if (credits < 0) + credits = max_t(int, -nfc_credits, credits); + nfc_credits += credits; tb_port_dbg(port, "adding %d NFC credits to %lu", credits, |