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-bot+sashiko@kernel.org" <netdev-bot+sashiko@kernel.org>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"jk@codeconstruct.com.au" <jk@codeconstruct.com.au>,
	"andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"edumazet@kernel.org" <edumazet@kernel.org>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"pabeni@redhat.com" <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 v2] mctp i2c: fix double free of midev on netdev register failure
Date: Wed, 11 Nov 2026 04:19:25 +0000	[thread overview]
Message-ID: <DM8PR02MB8087B22F3FFB3A9561381BCF8E712@DM8PR02MB8087.namprd02.prod.outlook.com> (raw)
In-Reply-To: <179334949479.3134.2940952959452938540@kernel.org>

Hi Matt,

Sashiko found two problems in v2, and both come from removing
ndo_uninit, so I'd like to bring it back in v3, just without the free
this time.

It turns out ndo_uninit was also dropping sel and emptying tx_queue,
and it's the only hook the core calls after dev_close() but before
waiting for the last netdev ref. If NETDEV_REGISTER fails, sel's ref is
never dropped and register hangs. On a normal unregister, a skb left in
tx_queue can keep the netdev pinned.

So in v3 ndo_uninit just drops sel and empties tx_queue. Both are fine
to run twice, so freeing midev and the put_device()s still only happen
in mctp_i2c_midev_free(), from mctp_i2c_unregister() like you suggested.

I did look at keeping ndo_uninit out. That would mean only picking sel
after mctp_register_netdev() succeeds, and calling netif_tx_disable()
before emptying tx_queue in mctp_i2c_unregister(). It works around the
core's ordering rather than using the hook meant for it, and both bits
need a comment to explain why they're there. It also doesn't cover the
unlock marker, which release_flow() still queues after the purge. So
I'd rather go with ndo_uninit, but happy to switch if you prefer.

BR,
Kenny


The pre-existing one is in the mctp core rather than mctp-i2c, so I'll
leave it out of this fix.

pw-bot: cr

      reply	other threads:[~2026-11-11  4:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27  5:37 Kenny Hsieh
2026-10-27  5:41 ` netdev-bot+sinfo
2026-10-27  5:55   ` Kenny Hsieh
2026-10-30  8:38 ` netdev-bot+sashiko
2026-11-11  4:19   ` Kenny Hsieh [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=DM8PR02MB8087B22F3FFB3A9561381BCF8E712@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-bot+sashiko@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®