Re: [PATCH net v2 3/3] net: fealnx: allocate the card index from an IDA
From: Andrew Lunn
Date: Fri Oct 02 2026 - 16:29:54 EST
On Fri, Oct 02, 2026 at 02:10:10PM +0000, Жамбакиев Радий Рикардинович wrote:
> From: Radiy Zhambakiev <r.zhambakiev@xxxxxxxxxxxxxxxxx>
>
> card_idx is a static counter that is incremented on every probe.
> It can overflow and wrap to a negative value, which then indexes
> options[] and full_duplex[] out of bounds. Large values also no
> longer fit in the 12-byte boardname[] buffer.
>
> Allocate the card index from an IDA and free it on probe failure and
> remove. The IDA reuses ids on re-add, preserving the options[] and
> full_duplex[] mapping by probe order.
>
> Store the id in the driver-private data so fealnx_remove_one() can
> free it, and size boardname to hold a full 32-bit id.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
How have you tested this?
The advantage of the KISS approach is it is stupid, so unlikely to be
wrong. The complexity here is much higher, so it is more likely to be
wrong. That is something we have to considered.
Have you put it into a loop, and probed it 10342432341 times, on real
hardware?
Andrew