From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Simon Horman <horms@kernel.org>
Cc: davem@davemloft.net,
Pantelis Antoniou <pantelis.antoniou@gmail.com>,
Andrew Lunn <andrew@lunn.ch>, Jakub Kicinski <kuba@kernel.org>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
Russell King <linux@armlinux.org.uk>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Florian Fainelli <f.fainelli@gmail.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
thomas.petazzoni@bootlin.com,
Herve Codina <herve.codina@bootlin.com>,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH net-next 6/6] net: ethernet: fs_enet: phylink conversion
Date: Thu, 29 Aug 2024 10:46:06 +0200 [thread overview]
Message-ID: <20240829104606.4ba68402@device-28.home> (raw)
In-Reply-To: <20240828163224.GT1368797@kernel.org>
Hello Simon,
On Wed, 28 Aug 2024 17:32:24 +0100
Simon Horman <horms@kernel.org> wrote:
> On Wed, Aug 28, 2024 at 11:51:02AM +0200, Maxime Chevallier wrote:
> > fs_enet is a quite old but still used Ethernet driver found on some NXP
> > devices. It has support for 10/100 Mbps ethernet, with half and full
> > duplex. Some variants of it can use RMII, while other integrations are
> > MII-only.
> >
> > Add phylink support, thus removing custom fixed-link hanldling.
> >
> > This also allows removing some internal flags such as the use_rmii flag.
> >
> > Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
>
> Hi Maxime,
>
> Some minor issues from my side: not a full review by any stretch of
> the imagination.
>
> ...
>
> > @@ -911,7 +894,7 @@ static int fs_enet_probe(struct platform_device *ofdev)
> > if (!IS_ERR(clk)) {
> > ret = clk_prepare_enable(clk);
> > if (ret)
> > - goto out_deregister_fixed_link;
> > + goto out_phylink;
> >
> > fpi->clk_per = clk;
> > }
>
> This goto will result in a dereference of fep.
> But fep is not initialised until the following line,
> which appears a little below this hunk.
>
> fep = netdev_priv(ndev);
Nice catch, the goto should rather go to out_free_fpi.
>
> This goto will also result in the function returning without
> releasing clk.
ah yes, it's never disabled_unprepared, the phylink cleanup label is at
the wrong spot. I'll include a patch in the next iteration to make use
of devm_clk_get_enabled(), that should simplify all of that.
> Both flagged by Smatch.
>
> > @@ -936,6 +919,26 @@ static int fs_enet_probe(struct platform_device *ofdev)
> > fep->fpi = fpi;
> > fep->ops = ops;
> >
> > + fep->phylink_config.dev = &ndev->dev;
> > + fep->phylink_config.type = PHYLINK_NETDEV;
> > + fep->phylink_config.mac_capabilities = MAC_10 | MAC_100;
> > +
> > + __set_bit(PHY_INTERFACE_MODE_MII,
> > + fep->phylink_config.supported_interfaces);
> > +
> > + if (of_device_is_compatible(ofdev->dev.of_node, "fsl,mpc5125-fec"))
> > + __set_bit(PHY_INTERFACE_MODE_RMII,
> > + fep->phylink_config.supported_interfaces);
> > +
> > + phylink = phylink_create(&fep->phylink_config, dev_fwnode(fep->dev),
> > + phy_mode, &fs_enet_phylink_mac_ops);
> > + if (IS_ERR(phylink)) {
> > + ret = PTR_ERR(phylink);
> > + goto out_free_fpi;
>
> This also appears to leak clk, as well as ndev.
Thanks, will be addressed in V2.
> I didn't look for other cases.
I'll go over the cleanup path, thanks for checking this !
Thanks,
Maxime
next prev parent reply other threads:[~2024-08-29 8:46 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-28 9:50 [PATCH net-next 0/6] net: ethernet: fs_enet: Cleanup and phylink conversion Maxime Chevallier
2024-08-28 9:50 ` [PATCH net-next 1/6] net: ethernet: fs_enet: convert to SPDX Maxime Chevallier
2024-08-28 10:12 ` Christophe Leroy
2024-08-28 9:50 ` [PATCH net-next 2/6] net: ethernet: fs_enet: cosmetic cleanups Maxime Chevallier
2024-08-28 10:16 ` Christophe Leroy
2024-08-28 9:50 ` [PATCH net-next 3/6] net: ethernet: fs_enet: drop the .adjust_link custom fs_ops Maxime Chevallier
2024-08-28 10:18 ` Christophe Leroy
2024-08-28 9:51 ` [PATCH net-next 4/6] net: ethernet: fs_enet: drop unused phy_info and mii_if_info Maxime Chevallier
2024-08-28 10:25 ` Christophe Leroy
2024-08-28 9:51 ` [PATCH net-next 5/6] net: ethernet: fs_enet: fcc: use macros for speed and duplex values Maxime Chevallier
2024-08-28 10:27 ` Christophe Leroy
2024-08-28 9:51 ` [PATCH net-next 6/6] net: ethernet: fs_enet: phylink conversion Maxime Chevallier
2024-08-28 10:38 ` Russell King (Oracle)
2024-08-28 11:44 ` Maxime Chevallier
2024-08-28 13:54 ` Russell King (Oracle)
2024-08-28 14:31 ` Maxime Chevallier
2024-08-28 16:32 ` Simon Horman
2024-08-29 8:46 ` Maxime Chevallier [this message]
2024-08-28 10:10 ` [PATCH net-next 0/6] net: ethernet: fs_enet: Cleanup and " Christophe Leroy
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=20240829104606.4ba68402@device-28.home \
--to=maxime.chevallier@bootlin.com \
--cc=andrew@lunn.ch \
--cc=christophe.leroy@csgroup.eu \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=herve.codina@bootlin.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pantelis.antoniou@gmail.com \
--cc=thomas.petazzoni@bootlin.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).