From: Andrew Lunn <andrew@lunn.ch>
To: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Linus Walleij <linus.walleij@linaro.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: dsa: mv88e6xxx: fix unreleased fwnode_handle in setup_port()
Date: Sun, 20 Oct 2024 16:47:07 +0200 [thread overview]
Message-ID: <612445d2-d7c8-4bda-a070-e2c0ebbf3d4e@lunn.ch> (raw)
In-Reply-To: <f148a61d-4ad5-4f62-b1f0-d216e1873067@gmail.com>
On Sun, Oct 20, 2024 at 12:21:07AM +0200, Javier Carrasco wrote:
> On 19/10/2024 23:59, Andrew Lunn wrote:
> > On Sat, Oct 19, 2024 at 10:16:49PM +0200, Javier Carrasco wrote:
> >> 'ports_fwnode' is initialized via device_get_named_child_node(), which
> >> requires a call to fwnode_handle_put() when the variable is no longer
> >> required to avoid leaking memory.
> >>
> >> Add the missing fwnode_handle_put() after 'ports_fwnode' has been used
> >> and is no longer required.
> >
> > As you point out, the handle is obtained with
> > device_get_named_child_node(). It seems odd to use a fwnode_ function
> > not a device_ function to release the handle. Is there a device_
> > function?
> >
> > Andrew
>
>
> Hi Andrew,
>
> device_get_named_child_node() receives a pointer to a *device*, and
> returns a child node (a pointer to an *fwnode_handle*). That is what has
> to be released, and therefore fwnode_handle_put() is the right one.
>
> Note that device_get_named_child_node() documents how to release the
> fwnode pointer:
>
> "The caller is responsible for calling fwnode_handle_put() on the
> returned fwnode pointer."
O.K. I just don't like asymmetric APIs. They often lead to bugs, just
look wrong, and make reviewers ask questions...
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
next prev parent reply other threads:[~2024-10-20 14:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-19 20:16 Javier Carrasco
2024-10-19 21:59 ` Andrew Lunn
2024-10-19 22:21 ` Javier Carrasco
2024-10-20 14:47 ` Andrew Lunn [this message]
2024-10-20 17:16 ` Linus Walleij
2024-10-28 13:30 ` patchwork-bot+netdevbpf
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=612445d2-d7c8-4bda-a070-e2c0ebbf3d4e@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=javier.carrasco.cruz@gmail.com \
--cc=kuba@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.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®