Re: [PATCH net] mctp i2c: fix double free of midev on netdev register failure
From: Matt Johnston
Date: Thu Oct 22 2026 - 04:27:50 EST
On Thu, 2026-10-22 at 07:22 +0000, Kenny Hsieh wrote:
>
> Agreed, that is cleaner than making the free idempotent. Here's what I'm
> planning, let me know if it looks right and I'll go ahead:
>
> - in mctp_i2c_unregister(), deselect mcli->sel if it points at this
> midev, before mctp_unregister_netdev(), so its dev_hold() doesn't
> block the unregister.
> - call mctp_i2c_midev_free() after mctp_unregister_netdev() and before
> free_netdev(), and take the sel handling out of it since that now
> happens earlier.
> - leave the mctp_i2c_add_netdev() error path calling
> mctp_i2c_midev_free() as it is, which then becomes the only free on
> a failed register.
> - delete mctp_i2c_ndo_uninit() and .ndo_uninit.
Yes, that looks good.
Cheers,
Matt