[PATCH net-next v14 12/13] net: ethtool: strset: Allow querying phy stats by index

Simon Horman horms at kernel.org
Wed Jul 3 13:18:51 PDT 2024


On Wed, Jul 03, 2024 at 08:55:15AM +0200, Maxime Chevallier wrote:
> Hello Simon,
> 
> On Tue, 2 Jul 2024 11:54:11 +0100
> Simon Horman <horms at kernel.org> wrote:
> 
> > On Mon, Jul 01, 2024 at 03:17:58PM +0200, Maxime Chevallier wrote:
> > > The ETH_SS_PHY_STATS command gets PHY statistics. Use the phydev pointer
> > > from the ethnl request to allow query phy stats from each PHY on the
> > > link.
> > > 
> > > Signed-off-by: Maxime Chevallier <maxime.chevallier at bootlin.com>
> > > ---
> > >  net/ethtool/strset.c | 24 +++++++++++++++++-------
> > >  1 file changed, 17 insertions(+), 7 deletions(-)
> > > 
> > > diff --git a/net/ethtool/strset.c b/net/ethtool/strset.c  
> > 
> > ...
> > 
> > > @@ -279,6 +280,8 @@ static int strset_prepare_data(const struct ethnl_req_info *req_base,
> > >  	const struct strset_req_info *req_info = STRSET_REQINFO(req_base);
> > >  	struct strset_reply_data *data = STRSET_REPDATA(reply_base);
> > >  	struct net_device *dev = reply_base->dev;
> > > +	struct nlattr **tb = info->attrs;  
> > 
> > Hi Maxime,
> > 
> > Elsewhere in this function it is assumed that info may be NULL.
> > But here it is dereferenced unconditionally.
> 
> Hmm in almst all netlink commands we do dereference the genl_info *info
> pointer without checks.
> 
> I've looked into net/netlink/genetlink.c to backtrack call-sites and it
> looks to be that indeed info can't be NULL (either populated from
> genl_start() or genl_family_rcv_msg_doit(). Maybe Jakub can confirm
> this ?
> 
> If what I say above is correct, I can include a small patch to remove
> the un-necessary check that makes smatch think the genl_info pointer can
> be NULL.

Thanks for following up.
Assuming that is true (I did not check yet) then I agree.
And I don't think such a change needs to block this patchset.



More information about the linux-arm-kernel mailing list