mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kenny Hsieh <kenny_hsieh@jabil.com>
To: Matt Johnston <matt@codeconstruct.com.au>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Jeremy Kerr <jk@codeconstruct.com.au>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"davem@davemloft.net" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net] mctp i2c: fix double free of midev on netdev register failure
Date: Thu, 22 Oct 2026 07:22:17 +0000	[thread overview]
Message-ID: <DM8PR02MB8087DCE3AE16D853D284FF2D8E652@DM8PR02MB8087.namprd02.prod.outlook.com> (raw)
In-Reply-To: <51bf6b10b2fc1c5d6ed7234e61067869380eebad.camel@codeconstruct.com.au>

Hi Matt,

On Thu, 2026-10-22 at 12:39 +0800, Matt Johnston wrote:
> I wonder if it would be better to delete mctp_i2c_ndo_uninit() and move the
> the mctp_i2c_midev_free() to mctp_i2c_unregister(), before free_netdev().
> Then the free sequence would be symmetrical with the init sequence in
> mctp_i2c_add_netdev.

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.

  reply	other threads:[~2026-10-22  7:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22  3:17 Kenny Hsieh
2026-10-22  4:39 ` Matt Johnston
2026-10-22  7:22   ` Kenny Hsieh [this message]
2026-10-22  8:24     ` Matt Johnston

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM8PR02MB8087DCE3AE16D853D284FF2D8E652@DM8PR02MB8087.namprd02.prod.outlook.com \
    --to=kenny_hsieh@jabil.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=jk@codeconstruct.com.au \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt@codeconstruct.com.au \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®