Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3889211rdb; Mon, 11 Dec 2023 03:08:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvErV6IA/ME5k1USFpGA2R1hyYZT2XI3k4x982lISoo6KBJDpdvFzGEUdTHEIcWApvhXgq X-Received: by 2002:a05:6359:1b87:b0:170:17eb:14c3 with SMTP id ur7-20020a0563591b8700b0017017eb14c3mr1869693rwb.51.1702292891709; Mon, 11 Dec 2023 03:08:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702292891; cv=none; d=google.com; s=arc-20160816; b=iZ8uK8ALw+kIHd7fjLevmtUPlcoA9PceKYRxIABp79sv1qYmYNLSnkqnN2AJgDeRvc cr+dOfJrZfLj31uDCSk1UH9R1uRQzvLm+rn4YgCSA8sVIKeK8YRiW8G1tgoVxQIPsoG6 pksB+QautH7CXHKM88DiSO3TyGUrM9Wp96ALg3MltacjcruNwLkqLtbIMtMSWAaNlAb+ pphDdqMaMi59mLqCnLvBbNk1npJxfYrnGMlywFPPTgMMDVo94xMV85VL04YX6t9r1A5l G1YEyXTpAFUgqIZizHlgdmVqnqAJ8kWGvHkUNQvCeZIECZgDfUXH8IXjOoWxwads3nyZ h4ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=lAhFpsV1S54PTdsFeohfVvq4D1Bry0V4SWQaEvqmkcQ=; fh=F/VLy7Uh4D/AZO3TBKmfGHPJ+T2M/GLaApEBM6y9SsQ=; b=f2eIYd6aZre+vV00M/LuxLT+tCAc+Z96Xj0L/OW/7adnLzHI4i5g/8cufrGg7lMhPZ x/5xP6EX1ZBlCXEIuSvoG2Wp/2L9sxIk+Na269zFfoD0y3G6CvNHZweaKgcgHcxHmnqa 0QtZWsb+tjm8ivL4qA9G/jJoWwRjF5dW1N2V6XgdbybhAbHv9adZKPLIl6ze2ypSYLZE 7Iv2GMHdHshihB3KkY4e3xnV1tc/8+1CruOzbAlpKM12fHqS+bJrQoWhWPAt0RsjxzzF opoRgNa8NZZCyehWiZWq9aPW9rPiOIet09eV5HOgXTIEkbCOCuELAoP8yT9x8/wLsS/J kFjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=iBbc8Stk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id it24-20020a056a00459800b006ce707e00d3si5916911pfb.241.2023.12.11.03.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 03:08:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=iBbc8Stk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 4A77580A9AA0; Mon, 11 Dec 2023 03:08:06 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234497AbjLKLHs (ORCPT + 99 others); Mon, 11 Dec 2023 06:07:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231734AbjLKLHr (ORCPT ); Mon, 11 Dec 2023 06:07:47 -0500 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68EC2B0; Mon, 11 Dec 2023 03:07:52 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id D1B0DE000E; Mon, 11 Dec 2023 11:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1702292871; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lAhFpsV1S54PTdsFeohfVvq4D1Bry0V4SWQaEvqmkcQ=; b=iBbc8StkgE3itF5NdrUN3K/zQbyy+ux8TUa3KZt+Z0IbKHgCBPLtce+yrrDZKX0YaRKzbx B81wusD7Lf+06jMJpoNqHEzMEtwlfLgA9zlm6qwLfEK7zUUzVuBI+5wn4qQCOoywZAlQIK +hShiEOMl1r88Cd2DunFVkfijcUhhRcQ9eypL65pMm8oRsFWvrSQO9h4uC89AGLVJzzMRt jnSLVXENCbXGF335vlDG8TsgLhZ/A1mBIkoKYzn94UgQksO508yyozwwZYHqx66k+AqzgG cIbOm4sXo0/VkeVljybRtr+e1LUzQalrqHiM02YcQN4Y2FKXpYNd32HiaOjt3w== Date: Mon, 11 Dec 2023 12:07:48 +0100 From: Maxime Chevallier To: Simon Horman 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?B?Tmljb2zDsg==?= Veronese Subject: Re: [RFC PATCH net-next v3 07/13] net: ethtool: Introduce a command to list PHYs on an interface Message-ID: <20231211120748.0eeb15cc@device.home> In-Reply-To: <20231209170457.GB5817@kernel.org> References: <20231201163704.1306431-1-maxime.chevallier@bootlin.com> <20231201163704.1306431-8-maxime.chevallier@bootlin.com> <20231209170457.GB5817@kernel.org> Organization: Bootlin X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-GND-Sasl: maxime.chevallier@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email 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 (pete.vger.email [0.0.0.0]); Mon, 11 Dec 2023 03:08:06 -0800 (PST) Hi Simon, On Sat, 9 Dec 2023 17:04:57 +0000 Simon Horman wrote: > 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 Ah true, let me also fix that in the next revision. Thanks for the review, Maxime