From: Matt Johnston <matt@codeconstruct.com.au>
To: Kenny Hsieh <kenny_hsieh@jabil.com>,
"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 16:24:19 +0800 [thread overview]
Message-ID: <f8c47a860a37c36221a62f1afb0593bbd82e3501.camel@codeconstruct.com.au> (raw)
In-Reply-To: <DM8PR02MB8087DCE3AE16D853D284FF2D8E652@DM8PR02MB8087.namprd02.prod.outlook.com>
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
prev parent reply other threads:[~2026-10-22 8:24 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
2026-10-22 8:24 ` Matt Johnston [this message]
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=f8c47a860a37c36221a62f1afb0593bbd82e3501.camel@codeconstruct.com.au \
--to=matt@codeconstruct.com.au \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=jk@codeconstruct.com.au \
--cc=kenny_hsieh@jabil.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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®