thunderbolt: Unwind TMU configuration if tb_switch_set_tmu_mode_params() fails
authorMika Westerberg <mika.westerberg@linux.intel.com>
Tue, 7 Nov 2023 11:06:25 +0000 (13:06 +0200)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Thu, 14 Dec 2023 06:07:44 +0000 (08:07 +0200)
Dan reported that the kernel test robot found an issue with the TMU code
namely in tb_switch_tmu_change_mode() where we should actually go back
to the previous mode in case of failure instead of just returning back
the error. Fix this by unwinding the configuration as we do with the
other error paths in this function.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202311030814.AXtCk7PO-lkp@intel.com/
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/thunderbolt/tmu.c

index 11f2aec..9a259c7 100644 (file)
@@ -894,7 +894,7 @@ static int tb_switch_tmu_change_mode(struct tb_switch *sw)
 
        ret = tb_switch_set_tmu_mode_params(sw, sw->tmu.mode_request);
        if (ret)
-               return ret;
+               goto out;
 
        /* Program the new mode and the downstream router lane adapter */
        switch (sw->tmu.mode_request) {