drivers/thunderbolt/tmu.c:617 tb_switch_tmu_change_mode() warn: missing unwind goto?

From: Dan Carpenter
Date: Fri Nov 03 2023 - 02:01:49 EST


Hi Mika,

FYI, the error/warning was bisected to this commit, please ignore it if it's irrelevant.

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 4652b8e4f3ffa48c706ec334f048c217a7d9750d
commit: c437dcb18310f296eb9db58a361f309f7817014d thunderbolt: Fix a couple of style issues in TMU code
config: i386-randconfig-141-20231102 (https://download.01.org/0day-ci/archive/20231103/202311030814.AXtCk7PO-lkp@xxxxxxxxx/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce: (https://download.01.org/0day-ci/archive/20231103/202311030814.AXtCk7PO-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
| Closes: https://lore.kernel.org/r/202311030814.AXtCk7PO-lkp@xxxxxxxxx/

smatch warnings:
drivers/thunderbolt/tmu.c:617 tb_switch_tmu_change_mode() warn: missing unwind goto?

vim +617 drivers/thunderbolt/tmu.c

c437dcb18310f2 Mika Westerberg 2022-10-07 596 static int tb_switch_tmu_change_mode(struct tb_switch *sw)
b017a46d486cd4 Gil Fine 2022-05-26 597 {
b017a46d486cd4 Gil Fine 2022-05-26 598 struct tb_port *up, *down;
b017a46d486cd4 Gil Fine 2022-05-26 599 int ret;
b017a46d486cd4 Gil Fine 2022-05-26 600
b017a46d486cd4 Gil Fine 2022-05-26 601 up = tb_upstream_port(sw);
7ce542219b6323 Gil Fine 2022-09-23 602 down = tb_switch_downstream_port(sw);
b017a46d486cd4 Gil Fine 2022-05-26 603 ret = tb_port_tmu_set_unidirectional(down, sw->tmu.unidirectional_request);
b017a46d486cd4 Gil Fine 2022-05-26 604 if (ret)
b017a46d486cd4 Gil Fine 2022-05-26 605 goto out;
b017a46d486cd4 Gil Fine 2022-05-26 606
b017a46d486cd4 Gil Fine 2022-05-26 607 if (sw->tmu.unidirectional_request)
7ce542219b6323 Gil Fine 2022-09-23 608 ret = tb_switch_tmu_rate_write(tb_switch_parent(sw),
7ce542219b6323 Gil Fine 2022-09-23 609 sw->tmu.rate_request);
b017a46d486cd4 Gil Fine 2022-05-26 610 else
b017a46d486cd4 Gil Fine 2022-05-26 611 ret = tb_switch_tmu_rate_write(sw, sw->tmu.rate_request);
b017a46d486cd4 Gil Fine 2022-05-26 612 if (ret)
b017a46d486cd4 Gil Fine 2022-05-26 613 return ret;

These error paths should be goto out;

b017a46d486cd4 Gil Fine 2022-05-26 614
b017a46d486cd4 Gil Fine 2022-05-26 615 ret = tb_switch_set_tmu_mode_params(sw, sw->tmu.rate_request);
b017a46d486cd4 Gil Fine 2022-05-26 616 if (ret)
b017a46d486cd4 Gil Fine 2022-05-26 @617 return ret;

Same. (I guess before goto out was a do-nothing goto so it didn't
matter).

b017a46d486cd4 Gil Fine 2022-05-26 618
b017a46d486cd4 Gil Fine 2022-05-26 619 ret = tb_port_tmu_set_unidirectional(up, sw->tmu.unidirectional_request);
b017a46d486cd4 Gil Fine 2022-05-26 620 if (ret)
b017a46d486cd4 Gil Fine 2022-05-26 621 goto out;
b017a46d486cd4 Gil Fine 2022-05-26 622
b017a46d486cd4 Gil Fine 2022-05-26 623 ret = tb_port_tmu_time_sync_enable(down);
b017a46d486cd4 Gil Fine 2022-05-26 624 if (ret)
b017a46d486cd4 Gil Fine 2022-05-26 625 goto out;
b017a46d486cd4 Gil Fine 2022-05-26 626
b017a46d486cd4 Gil Fine 2022-05-26 627 ret = tb_port_tmu_time_sync_enable(up);
b017a46d486cd4 Gil Fine 2022-05-26 628 if (ret)
b017a46d486cd4 Gil Fine 2022-05-26 629 goto out;
b017a46d486cd4 Gil Fine 2022-05-26 630
b017a46d486cd4 Gil Fine 2022-05-26 631 return 0;
b017a46d486cd4 Gil Fine 2022-05-26 632
b017a46d486cd4 Gil Fine 2022-05-26 633 out:
c437dcb18310f2 Mika Westerberg 2022-10-07 634 tb_switch_tmu_change_mode_prev(sw);
b017a46d486cd4 Gil Fine 2022-05-26 635 return ret;
b017a46d486cd4 Gil Fine 2022-05-26 636 }

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki