🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
4 messages
4 total messages Started by Shirong Zhao Tue, 17 Nov 2026 04:13
[PATCH net] net: wan: farsync: reuse card slots after hot-unplug
#17617
Author: Shirong Zhao
Date: Tue, 17 Nov 2026 04:13
56 lines
10096 bytes
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;
Re: [PATCH net] net: wan: farsync: reuse card slots after hot-unplug
#17618
Author: netdev-bot+sinfo
Date: Tue, 17 Nov 2026 04:16
23 lines
8480 bytes
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.
Re: [PATCH net] net: wan: farsync: reuse card slots after hot-unplug
#17619
Author: Shirong Zhao
Date: Tue, 17 Nov 2026 04:26
25 lines
9570 bytes
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.
Re: [PATCH net] net: wan: farsync: reuse card slots after hot-unplug
#17911
Author: Andrew Lunn
Date: Tue, 17 Nov 2026 14:07
11 lines
8088 bytes
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")

What does this tell you?

That nobody cares. Why change this?

    Andrew

---
pw-bot: cr
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads