Re: [PATCH net] net: wan: farsync: reuse card slots after hot-unplug
From: Shirong Zhao
Date: Mon Nov 16 2026 - 23:27:16 EST
Hi,
Thanks. To answer the two points:
- How it was found: this came out of an LLM-assisted static review of
mainline, looking for resource bookkeeping bugs in drivers. It was
not a user report and not a syzbot finding.
- Triggered? Not observed at runtime: I do not have FarSync hardware,
so this is a code-inspection finding. The failure mode is
deterministic, though: fst_card_array[] has FST_MAX_CARDS slots,
fst_add_one() indexes it with a file-static counter that is only
ever incremented, and fst_remove_one() clears the slot without
decrementing the counter. Every probe/remove cycle therefore
consumes one slot permanently, so after FST_MAX_CARDS cycles probe
fails with "FarSync: too many cards" although no card is present.
A probe failure after the slot was claimed leaks the slot the same
way.
The patch picks the first free slot instead of the counter, so slots
are reused after removal; card->card_no already records the slot that
fst_remove_one() clears, so the rest of the driver is unchanged.
Compile-tested against mainline 666539eecdf4 with W=1, no warnings.