Thread (4 messages) 4 messages, 2 authors, 3d ago

Re: [PATCH net] mctp i2c: fix double free of midev on netdev register failure

flat view

From: Matt Johnston <matt@codeconstruct.com.au>
Date: 2026-10-22 08:24:23
Also in: lkml, stable

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help