Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3049475rdb; Sat, 9 Dec 2023 09:05:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXPOubRJU/ihMl6AEp/graV0eaOHm8LtcuUbHm1TBnL1oPnBPBsqJ8INCNB9e60tQk65ax X-Received: by 2002:a17:902:ea0a:b0:1d0:b594:3332 with SMTP id s10-20020a170902ea0a00b001d0b5943332mr1148150plg.115.1702141509814; Sat, 09 Dec 2023 09:05:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702141509; cv=none; d=google.com; s=arc-20160816; b=L31G7UB/3ZRB9OYBpiMLMZolTpu05JPHdNvD/djpCN9ByYF/yiUuRxDTTbUrSDez1n LgmequZBP8wcCf7i9UkPjTtmnrTWhSZF8o/7Vlh/yX3o4a+b6VZS3whOdQAEZSGWeilS 2Tn+x9rV1vhtWvatcWTxQjxrJPtVzw0++HbMwuNZ29U5QzEb7O5pzk+B0yXmn8H3k6Yx Hlovn8zv2c7tFO+BLJCjUNwtBdYrC0mwhqQRiKzkEHsIbpenyAX8IBO/H08EqlFB79tr wwbCI4PV5lP9L2nr1+uJWg4vx04R6sbVW6+N9GQ9nupiQDLHlf/VXCGreXysiBFSrkYY hedQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ghnrbXmqXJCS4t+lPIJ3A4plStB9GPTrxYUrbUqOoX4=; fh=45bi2tkHiIxkR4AeeXs4jT/AokC/uWZabNA35zm/75w=; b=BULGUp1k8VAQWQMBXQcz/QTa2bKMmNcW7F6aPlHCdU7Aq5oeSEyl/DjGLQhUC5wt+N VUEYm4uEfg5s+Xqju0cqRp7Wu8cG26XLEChi5Si54W9jqcj3tPYoIMhUNEQ0usaV72Nn 8l2imIqbkWO9XJYtNg4ASmuvWkoAx7GQMLbFD8l7yHvmRQsCRkSdEs9QacX94UZgZ6NJ 1Xc3/sSeni9NF+a/xp7CcVEsVbrMi00Gh6oTgF1xJJImccrmM+PKzvG4c9dFqctFY/hl YeHCtzL+8gN9K6WPrcoeKhj1GGdMz4jTjOpfvSnagpRdtIHktTmzB5Y9kutHaYAffXoa Qubw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="kuW3s/gq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id s15-20020a170902b18f00b001d0b9edced7si3316693plr.581.2023.12.09.09.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 09:05:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="kuW3s/gq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5197880615FE; Sat, 9 Dec 2023 09:05:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230439AbjLIRE7 (ORCPT + 99 others); Sat, 9 Dec 2023 12:04:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbjLIRE6 (ORCPT ); Sat, 9 Dec 2023 12:04:58 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C58CA121 for ; Sat, 9 Dec 2023 09:05:04 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9783C433C7; Sat, 9 Dec 2023 17:04:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702141504; bh=23L3WN6QiOepynHV4/l1rgY8ayFp8shdyR9qFwIfo4U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kuW3s/gq4XmvI+zazP8ZslY+PEh1eN/BTZsf9FuLTCy32Wy27zQJQDo+9kpSkce3w z36SwtpUkKPn35Wgp/vZK0KiGYpa4onEEzFdybM0ipkJlaz0x/jCIqga5fMvFx44SJ IWSwlPu/c84PKciUaUW/SOuUBj5p9kxhCWB2ImoSdTDP42v5W5rhUqrf/27jXDyS6n 0nqwiHIsmRP3hsU/nzMGz0hBqRo5ogqw71a8gCh7KPRy2v2Itk6+FqUjQ34oIBokQW k7OjDpgnPDDvxBSXWIMCGGQg2adV8tUHfv36S2tuQf/JwF7Jm0m0zJZfBhlg7Cw08u wvHZh7zjxuItA== Date: Sat, 9 Dec 2023 17:04:57 +0000 From: Simon Horman To: Maxime Chevallier Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?utf-8?B?S8O2cnk=?= Maincent , Jesse Brandeburg , Jonathan Corbet , Marek =?utf-8?B?QmVow7pu?= , Piergiorgio Beruto , Oleksij Rempel , =?utf-8?Q?Nicol=C3=B2?= Veronese Subject: Re: [RFC PATCH net-next v3 07/13] net: ethtool: Introduce a command to list PHYs on an interface Message-ID: <20231209170457.GB5817@kernel.org> References: <20231201163704.1306431-1-maxime.chevallier@bootlin.com> <20231201163704.1306431-8-maxime.chevallier@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231201163704.1306431-8-maxime.chevallier@bootlin.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 09 Dec 2023 09:05:08 -0800 (PST) On Fri, Dec 01, 2023 at 05:36:57PM +0100, Maxime Chevallier wrote: > As we have the ability to track the PHYs connected to a net_device > through the link_topology, we can expose this list to userspace. This > allows userspace to use these identifiers for phy-specific commands and > take the decision of which PHY to target by knowing the link topology. > > Add PHY_GET and PHY_DUMP, which can be a filtered DUMP operation to list > devices on only one interface. > > Signed-off-by: Maxime Chevallier ... > diff --git a/net/ethtool/phy.c b/net/ethtool/phy.c ... > +static int ethnl_phy_dump_one_dev(struct sk_buff *skb, struct net_device *dev, > + struct netlink_callback *cb) > +{ > + struct ethnl_phy_dump_ctx *ctx = (void *)cb->ctx; > + struct phy_req_info *pri = ctx->phy_req_info; > + struct phy_device_node *pdn; > + unsigned long index = 1; > + void *ehdr; > + int ret; > + > + pri->base.dev = dev; > + > + xa_for_each(&dev->link_topo.phys, index, pdn) { > + ehdr = ethnl_dump_put(skb, cb, > + ETHTOOL_MSG_PHY_GET_REPLY); > + if (!ehdr) { > + ret = -EMSGSIZE; > + break; > + } > + > + ret = ethnl_fill_reply_header(skb, dev, > + ETHTOOL_A_PHY_HEADER); > + if (ret < 0) { > + genlmsg_cancel(skb, ehdr); > + break; > + } > + > + memcpy(&pri->pdn, pdn, sizeof(*pdn)); > + ret = ethnl_phy_fill_reply(&pri->base, skb); > + > + genlmsg_end(skb, ehdr); > + } > + > + return ret; Hi Maxime, I am unsure if this can happen (or if I flagged this before) but if the loop runs zero times then ret is uninitialised here. Flagged by Smatch > +} ...