* [PATCH net] net: wan: farsync: reuse card slots after hot-unplug
@ 2026-11-17 4:13 Shirong Zhao
2026-11-17 4:16 ` netdev-bot+sinfo
0 siblings, 1 reply; 3+ messages in thread
From: Shirong Zhao @ 2026-11-17 4:13 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
farsync keeps fst_card_array[FST_MAX_CARDS] and a file-static
no_of_cards_added counter that is only ever incremented:
fst_card_array[no_of_cards_added] = card;
card->card_no = no_of_cards_added++;
fst_remove_one() clears the array slot but leaves the counter at its
last value, so every probe/remove cycle permanently consumes one slot.
After FST_MAX_CARDS cycles the driver fails probe with "FarSync: too
many cards" even though no card is present. A failed probe after the
slot was claimed leaks the slot the same way.
Pick the first free slot instead of an ever-growing 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.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Shirong Zhao <shxzhaosr@163.com>
---
drivers/net/wan/farsync.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
index 6508c53..a6fa4d3 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -2325,7 +2325,6 @@ static const struct net_device_ops fst_ops = {
static int
fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
- static int no_of_cards_added;
struct fst_card_info *card;
int err = 0;
int i;
@@ -2466,13 +2465,17 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent)
pci_set_drvdata(pdev, card);
/* Remainder of card setup */
- if (no_of_cards_added >= FST_MAX_CARDS) {
+ for (i = 0; i < FST_MAX_CARDS; i++) {
+ if (!fst_card_array[i])
+ break;
+ }
+ if (i == FST_MAX_CARDS) {
pr_err("FarSync: too many cards\n");
err = -ENOMEM;
goto card_array_fail;
}
- fst_card_array[no_of_cards_added] = card;
- card->card_no = no_of_cards_added++; /* Record instance and bump it */
+ fst_card_array[i] = card;
+ card->card_no = i;
err = fst_init_card(card);
if (err)
goto init_card_fail;
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] net: wan: farsync: reuse card slots after hot-unplug
2026-11-17 4:13 [PATCH net] net: wan: farsync: reuse card slots after hot-unplug Shirong Zhao
@ 2026-11-17 4:16 ` netdev-bot+sinfo
2026-11-17 4:26 ` Shirong Zhao
0 siblings, 1 reply; 3+ messages in thread
From: netdev-bot+sinfo @ 2026-11-17 4:16 UTC (permalink / raw)
To: Shirong Zhao; +Cc: netdev, linux-kernel
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: wan: farsync: reuse card slots after hot-unplug
2026-11-17 4:16 ` netdev-bot+sinfo
@ 2026-11-17 4:26 ` Shirong Zhao
0 siblings, 0 replies; 3+ messages in thread
From: Shirong Zhao @ 2026-11-17 4:26 UTC (permalink / raw)
To: netdev-bot+sinfo; +Cc: netdev, linux-kernel
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-17 4:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 4:13 [PATCH net] net: wan: farsync: reuse card slots after hot-unplug Shirong Zhao
2026-11-17 4:16 ` netdev-bot+sinfo
2026-11-17 4:26 ` Shirong Zhao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox