Netdev List
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Xuanqiang Luo <xuanqiang.luo@linux.dev>,
	netdev@vger.kernel.org, andrew@lunn.ch,
	maxime.chevallier@bootlin.com, kuba@kernel.org
Cc: hkallweit1@gmail.com, chleroy@kernel.org,
	qingfang.deng@siflower.com.cn, hao.guan@siflower.com.cn,
	linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com,
	linux-kernel@vger.kernel.org,
	Xuanqiang Luo <luoxuanqiang@kylinos.cn>
Subject: Re: [PATCH net v5 6/6] net: phy: avoid double-free after LED trigger registration failure
Date: Thu, 27 Aug 2026 13:40:46 +0200	[thread overview]
Message-ID: <e60be557-7020-46fc-9b07-d8b32f99f103@redhat.com> (raw)
In-Reply-To: <20260823035600.188864-7-xuanqiang.luo@linux.dev>

On 8/23/26 5:56 AM, Xuanqiang Luo wrote:
> From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
> 
> phy_led_triggers_register() frees phy_led_triggers when a speed trigger
> registration fails, but leaves the pointer set to the freed allocation
> before clearing phy_num_led_triggers.
> 
> phy_probe() ignores the registration error. If a later probe step fails,
> its error path calls phy_led_triggers_unregister(); normal teardown during
> an unbind or MDIO bus removal calls the same helper from phy_remove().
> In either case, the trigger count is zero, so the per-trigger unregister
> loop is skipped, but the dangling pointer is still freed unconditionally.
> 
> Clear the pointer when partial registration cleanup frees the array, and
> make phy_led_triggers_unregister() free the array only when its pointer is
> non-NULL.
> 
> Fixes: b7f0ee992adf ("net: phy: leds: fix memory leak")
> Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
I think an explicit ack from phy experts is needed here: sashiko has
flagged a few pre-existing issues on this patch:

https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260823035600.188864-1-xuanqiang.luo%40linux.dev

that IMHO bortderline to be addresses in this same series.

/P


      reply	other threads:[~2026-08-27 11:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-23  3:55 [PATCH net v5 0/6] net: phy: fix cleanup after probe failure Xuanqiang Luo
2026-08-23  3:55 ` [PATCH net v5 1/6] net: phy: split phy_probe() error paths Xuanqiang Luo
2026-08-23  3:55 ` [PATCH net v5 2/6] net: phy: unregister SFP upstream before port cleanup Xuanqiang Luo
2026-08-23  3:55 ` [PATCH net v5 3/6] net: phy: set PHY_READY after LED setup Xuanqiang Luo
2026-08-23  3:55 ` [PATCH net v5 4/6] net: phy: call driver remove when core initialization fails Xuanqiang Luo
2026-08-23  3:55 ` [PATCH net v5 5/6] net: phy: propagate errors from default port setup Xuanqiang Luo
2026-08-23  3:56 ` [PATCH net v5 6/6] net: phy: avoid double-free after LED trigger registration failure Xuanqiang Luo
2026-08-27 11:40   ` Paolo Abeni [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=e60be557-7020-46fc-9b07-d8b32f99f103@redhat.com \
    --to=pabeni@redhat.com \
    --cc=andrew@lunn.ch \
    --cc=chleroy@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hao.guan@siflower.com.cn \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=luoxuanqiang@kylinos.cn \
    --cc=maxime.chevallier@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=qingfang.deng@siflower.com.cn \
    --cc=xuanqiang.luo@linux.dev \
    /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