Re: [PATCH net v3 3/3] net: fealnx: bound card_idx to prevent out-of-bounds access

From: Andrew Lunn

Date: Wed Oct 21 2026 - 13:33:05 EST


> > + if (card_idx >= MAX_CARD_IDX) {
> > + dev_err(&pdev->dev, "card_idx is too big %d, aborting",
> > card_idx);
> > + return -ENODEV;
> > + }
> > card_idx++;
> card_idx can reach 100000 is it ok?

It is one of those stupid LLM issues which never happens, but
$DEVELOPER wants to fix it anyway.

If you unbind and bind the device lots, you can eventually get
card_idx to overflow. Assuming card_idx is a 32 bit int, and it takes
10ms to unbind/bind, you could make it overflow in about 18 months.

100,000 iterations makes it around 16 hours, which is feasible, so i
hope the submitted has tested it. But probably not, it is just
pointless LLM churn wasting all our time.

Andrew