Re: [PATCH net v2 1/2] net: thunderbolt: Release the Rx HopID that was handed out on mismatch

From
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date
2026-08-10 18:56:22
Also in
lkml, stable
Reply to
Fan Ye, 2026-08-10
On Mon, Aug 10, 2026 at 09:39:14AM +0000, Fan Ye via B4 Relay wrote:
tbnet_connected_work() asks for a specific input HopID and treats getting
a different one as a failure:

	ret = tb_xdomain_alloc_in_hopid(net->xd, net->remote_transmit_path);
	if (ret != net->remote_transmit_path) {
		netdev_err(net->dev, "failed to allocate Rx HopID\n");
		return;
	}
No need to cite the code, we all able to see it well from the source tree.
That call ends in ida_alloc_range(&xd->in_hopids, hopid,
xd->local_max_hopid, GFP_KERNEL), which allocates the lowest free id at
or above the one asked for. When the
wanted HopID is already taken it does not fail - it succeeds with the next
one - so this path returns with an id allocated and no reference to it
left anywhere. It stays allocated for the rest of the XDomain connection.

Forcing the branch by occupying the wanted HopID first shows the returned
id is a live allocation, not an error code:

  LEAKPROBE squat=8 requested=8 local_max_hopid=27
  LEAKPROBE real alloc ret=9
  thunderbolt-net 0-1.0 thunderbolt0: failed to allocate Rx HopID

Release the id when it is not the one we wanted, matching what the error
unwind at the end of the function already does for the expected id.
General hint: do not blindly copy'n'paste the Dostoevsky saga from AI. Squeeze
it and show (by rephrasing) that you also understand what's going on there.

-- 
With Best Regards,
Andy Shevchenko

Thread (5 messages) 5 messages, 2 authors, last reply 2026-08-10
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help