[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y4271Y9TtdiEgjn2@gvm01>
Date: Mon, 5 Dec 2022 10:37:25 +0100
From: Piergiorgio Beruto <piergiorgio.beruto@...il.com>
To: "Russell King (Oracle)" <linux@...linux.org.uk>
Cc: Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, Oleksij Rempel <o.rempel@...gutronix.de>
Subject: Re: [PATCH v2 net-next 1/4] net/ethtool: add netlink interface for
the PLCA RS
On Mon, Dec 05, 2022 at 09:28:51AM +0000, Russell King (Oracle) wrote:
> On Mon, Dec 05, 2022 at 02:41:35AM +0100, Piergiorgio Beruto wrote:
> > +int ethnl_set_plca_cfg(struct sk_buff *skb, struct genl_info *info)
> > +{
> > + struct ethnl_req_info req_info = {};
> > + struct nlattr **tb = info->attrs;
> > + const struct ethtool_phy_ops *ops;
> > + struct phy_plca_cfg plca_cfg;
> > + struct net_device *dev;
> > +
> > + bool mod = false;
> > + int ret;
> > +
> > + ret = ethnl_parse_header_dev_get(&req_info,
> > + tb[ETHTOOL_A_PLCA_HEADER],
> > + genl_info_net(info), info->extack,
> > + true);
> > + if (ret < 0)
> > + return ret;
> > +
> > + dev = req_info.dev;
> > +
> > + // check that the PHY device is available and connected
> > + if (!dev->phydev) {
> > + ret = -EOPNOTSUPP;
> > + goto out;
> > + }
>
> This check should really be done under the RTNL lock. phydevs can come
> and go with SFP cages.
>
> > +
> > + rtnl_lock();
Good point Russell, I'll fix that. And I wish to seize the opportunity
to remark that the same problem may be present in cabletest.c
(see below).
Maybe we should post a patch to fix that?
Thanks,
Piergiorgio
int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info)
{
struct ethnl_req_info req_info = {};
const struct ethtool_phy_ops *ops;
struct nlattr **tb = info->attrs;
struct net_device *dev;
int ret;
ret = ethnl_parse_header_dev_get(&req_info,
tb[ETHTOOL_A_CABLE_TEST_HEADER],
genl_info_net(info), info->extack,
true);
if (ret < 0)
return ret;
dev = req_info.dev;
if (!dev->phydev) {
ret = -EOPNOTSUPP;
goto out_dev_put;
}
rtnl_lock();
Powered by blists - more mailing lists