RE: [Intel-wired-lan] [PATCH net] igb: unregister the i2c adapter when register_netdev() fails

From: Singh, Ayush1X

Date: Tue Oct 27 2026 - 01:50:20 EST


> -----Original Message-----
> From: Linkui Xiao <xiaolinkui@xxxxxxx>
> Sent: 16 September 2026 18:58
> To: Nguyen, Anthony L <anthony.l.nguyen@xxxxxxxxx>; Kitszel, Przemyslaw <przemyslaw.kitszel@xxxxxxxxx>; andrew+netdev@xxxxxxx; davem@xxxxxxxxxxxxx; edumazet@xxxxxxxxxx; kuba@xxxxxxxxxx; pabeni@xxxxxxxxxx
> Cc: intel-wired-lan@xxxxxxxxxxxxxxxx; netdev@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; Linkui Xiao <xiaolinkui@xxxxxxxxxx>; stable@xxxxxxxxxxxxxxx
> Subject: [Intel-wired-lan] [PATCH net] igb: unregister the i2c adapter when register_netdev() fails
>
> From: Linkui Xiao <xiaolinkui@xxxxxxxxxx>
>
> igb_probe() sets up the bit-banging i2c adapter with igb_init_i2c() before it registers the netdev, but the err_register path only zeroes
adapter->i2c_adap instead of unregistering the adapter. On i350 parts,
where igb_init_i2c() really registers the bus, the adapter is therefore still registered when free_netdev() releases the memory that embeds it.
The i2c core keeps pointing at the freed adapter, so any later access to that bus dereferences freed memory, and the adapter number is leaked.
>
> Call igb_remove_i2c() instead, the same way igb_remove() tears the bus down. Move the helper next to igb_init_i2c() so that it is in scope for igb_probe(). i2c_del_adapter() returns early for an adapter that was never registered, so the parts without i2c support are unaffected.
>
> Fixes: 441fc6fdb47a ("igb: Add i2c interface to igb.")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Linkui Xiao <xiaolinkui@xxxxxxxxxx>
> ---
> drivers/net/ethernet/intel/igb/igb_main.c | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
>

Tested-by: Singh, Ayush1X < ayush1x.singh@xxxxxxxxx > (A Contingent worker at Intel)