From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DF7A3C41535 for ; Tue, 19 Dec 2023 08:58:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1jCGpJXa/OGBLIMgi4Ul7YMSwBW8tB9QIy8vZrh5DD4=; b=FRupLprbKdTd7P LvCAgqQYexLPNyF6jycPWApMSB2gRXIUk94g9+gSU/p5qlcoJ2bw9X46tvj/t0S67XBWDhym+uemX +t8BGemsz0mZuNXmB1Ah79MJQF/g4pYcaIncocijBEilBJUuAtiHEWxKxeeiHrLOHT75/3tpvpdU2 UHaVyxCdXOOh+D4oL9ngsbRITlWUrJo0KxPOTWAzRrtOus5z7gUrak2EJB/PL74arVi7qdchcnF+6 1bZ8xVIuH88i+kTcSAWNqr/p7UsCUc1b6TCXagdydlHRUeykhgd9BZW51RCUhwuj+XeifCHtlb5sv 0AhMuQ4JFC70A/nAz0XQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFVv2-00DNWi-1W; Tue, 19 Dec 2023 08:57:40 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFVuy-00DNVo-26 for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 08:57:38 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id CDF9AB8166D; Tue, 19 Dec 2023 08:57:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D49CAC433C7; Tue, 19 Dec 2023 08:57:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702976254; bh=Qdl2WTOHb4rTUwS9hPDzncPiZEnkbpJEzM85A3gmzoY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hNntwxVdsfrEB7fJ+mBfl5fRUwDuZSaMhdg+6Z0g4/+wp4Wc3XwfudEx4JdcLfO16 Mld/NrcEPGDK+Hu7SRevyZCr7gZGAPB1e3HSvMpW3SkrGW5R8SD48RgKcD9KqAsQgw sEVKEsxp/aAGCWqASiwnW7CU6oDYK5jrN661HMTohdO+NDs4FwecRk4t7RDNTpRk9G OogsU38OtIc8qsyAcec7Y03IBJyrUyX46+We9bQbEOYDFyZSE7yOlxtsqZECb6POwg +n+unclTpiSz7n1RCfXlAcj0g9vvC+zIyTV9aEWXOqVV+RdCGIuAlZ1Au7ilG/ydHd TprBpLr7klKhw== Date: Tue, 19 Dec 2023 08:55: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: [PATCH net-next v4 07/13] net: ethtool: Introduce a command to list PHYs on an interface Message-ID: <20231219085557.GB811967@kernel.org> References: <20231215171237.1152563-1-maxime.chevallier@bootlin.com> <20231215171237.1152563-8-maxime.chevallier@bootlin.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20231215171237.1152563-8-maxime.chevallier@bootlin.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_005736_985714_B692FFB3 X-CRM114-Status: GOOD ( 19.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Dec 15, 2023 at 06:12:29PM +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 Hi Maxime, some minor feedback from my side. > +static int ethnl_phy_parse_request(struct ethnl_req_info *req_base, > + struct nlattr **tb) > +{ > + struct phy_req_info *req_info = PHY_REQINFO(req_base); > + struct phy_link_topology *topo = &req_base->dev->link_topo; > + struct phy_device_node *pdn; nit: Please consider arranging local variables in reverse xmas tree order - longest line to shortest. > + > + if (!req_base->phydev) > + return 0; > + > + pdn = xa_load(&topo->phys, req_base->phydev->phyindex); > + memcpy(&req_info->pdn, pdn, sizeof(*pdn)); > + > + return 0; > +} ... > +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; I'm unsure if it can happen, but if the loop runs zero times then ret will be used uninitialised here. Flagged by Smatch. > +} ... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel