netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Cc: netdev@vger.kernel.org, andrew@lunn.ch, hkallweit1@gmail.com,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: mdio: get/put device node during (un)registration
Date: Tue, 2 Jan 2024 11:02:40 +0000	[thread overview]
Message-ID: <ZZPtUIRerqTI2/yh@shell.armlinux.org.uk> (raw)
In-Reply-To: <20231220045228.27079-2-luizluca@gmail.com>

On Wed, Dec 20, 2023 at 01:52:29AM -0300, Luiz Angelo Daros de Luca wrote:
> The __of_mdiobus_register() function was storing the device node in
> dev.of_node without increasing its reference count. It implicitly relied
> on the caller to maintain the allocated node until the mdiobus was
> unregistered.
> 
> Now, __of_mdiobus_register() will acquire the node before assigning it,
> and of_mdiobus_unregister_callback() will be called at the end of
> mdio_unregister().
> 
> Drivers can now release the node immediately after MDIO registration.
> Some of them are already doing that even before this patch.
> 
> Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>

I don't like this, certainly not the use of a method prefixed by a
double-underscore, and neither the conditional nature of "putting"
this. That alone seems to point to there being more issues.

I also notice that netdev have applied this without *any* review from
phylib maintainers. Grr.

Indeed there are more issues with the refcounting here. If one looks at
drivers/net/phy/mdio_bus.c::of_mdiobus_link_mdiodev(), we find this:

                if (addr == mdiodev->addr) {
                        device_set_node(dev, of_fwnode_handle(child));
                        /* The refcount on "child" is passed to the mdio
                         * device. Do _not_ use of_node_put(child) here.
                         */
                        return;

but there is nowhere that this refcount is dropped. 

Really, the patch should be addressing the problem rather than putting
a sticky-plaster over just one instance of it.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

  parent reply	other threads:[~2024-01-02 11:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-20  4:52 [PATCH net-next] net: mdio: get/put device node during (un)registration Luiz Angelo Daros de Luca
2024-01-01 13:10 ` patchwork-bot+netdevbpf
2024-01-02 11:02 ` Russell King (Oracle) [this message]
2024-01-02 21:57   ` Luiz Angelo Daros de Luca
2024-01-03  0:31     ` Jakub Kicinski
2024-01-03 10:22     ` Russell King (Oracle)
2024-01-03 12:01       ` Russell King (Oracle)
2024-01-03 21:50         ` Luiz Angelo Daros de Luca

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=ZZPtUIRerqTI2/yh@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luizluca@gmail.com \
    --cc=netdev@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).