Re: [PATCH net v2 1/2] net: thunderbolt: Release the Rx HopID that was handed out on mismatch
Andy Shevchenko <[email protected]>
| Newsgroups | org.kernel.vger.netdev,org.kernel.vger.linux-kernel,org.kernel.vger.stable |
|---|---|
| Organization | Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo |
| Message-ID | <[email protected]> |
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