From: Andrew Lunn <andrew@lunn.ch>
To: ZhaoJinming <zhaojinming@uniontech.com>
Cc: horms@kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org,
linux-kernel@vger.kernel.org, madalin.bucur@nxp.com,
netdev@vger.kernel.org, pabeni@redhat.com,
sean.anderson@linux.dev
Subject: Re: [PATCH v2 2/2] net: fman: use devm_kzalloc() for fman and rely on devres
Date: Mon, 22 Jun 2026 12:36:04 +0200 [thread overview]
Message-ID: <4692dda4-657a-4c00-9e65-cff4b79d19be@lunn.ch> (raw)
In-Reply-To: <20260622090505.2418478-2-zhaojinming@uniontech.com>
On Mon, Jun 22, 2026 at 05:05:05PM +0800, ZhaoJinming wrote:
> The driver now allocates the top-level struct fman with devm_kzalloc()
> so that its lifetime is bound to the device and resources are released
> automatically by the driver core on probe failure or device removal.
>
> Remove the explicit kfree(fman) from the error paths in fman_config()
> and read_dts_node() to avoid double-free/use-after-free and to follow
> the devm_ allocation convention.
>
> After of_find_matching_node() consumes fm_node's reference via
> of_node_put(from), the post-muram error paths no longer need to clean
> up fm_node, so replace goto fman_free with direct return ERR_PTR(err).
>
> This change complements the existing use of devm_* resources (irq,
> ioremap, etc.) and simplifies the error handling paths.
>
> Signed-off-by: ZhaoJinming <zhaojinming@uniontech.com>
Please take a read of:
https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html
Please read it all, but see section 1.7.4.
Andrew
---
pw-bot: cr
next prev parent reply other threads:[~2026-06-22 10:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-18 7:54 [PATCH] net: fman: fix clock and device node leak in probe error paths ZhaoJinming
2026-06-18 8:08 ` Madalin Bucur
2026-06-19 12:13 ` Simon Horman
2026-06-22 9:05 ` [PATCH v2 1/2] net: fman: fix clk reference leak in read_dts_node() ZhaoJinming
2026-06-22 9:05 ` [PATCH v2 2/2] net: fman: use devm_kzalloc() for fman and rely on devres ZhaoJinming
2026-06-22 10:36 ` Andrew Lunn [this message]
2026-06-23 6:16 ` 赵金明
2026-06-23 11:22 ` Andrew Lunn
2026-06-24 9:49 ` ZhaoJinming
2026-06-24 9:49 ` [PATCH v3] net: fman: fix use-after-free on IRQF_SHARED handler after probe failure ZhaoJinming
2026-06-25 16:42 ` Simon Horman
2026-06-26 9:53 ` 赵金明
2026-06-26 16:23 ` Simon Horman
2026-06-22 10:33 ` [PATCH v2 1/2] net: fman: fix clk reference leak in read_dts_node() Andrew Lunn
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=4692dda4-657a-4c00-9e65-cff4b79d19be@lunn.ch \
--to=andrew@lunn.ch \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=madalin.bucur@nxp.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sean.anderson@linux.dev \
--cc=zhaojinming@uniontech.com \
/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®