From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDF5E2F6184 for ; Mon, 2 Feb 2026 12:57:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.193 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770037049; cv=none; b=N0iGReoPjm7LTfwduSASeii1IQ/hK14Sw1gMHh6s/MldOAwaSagFIIsPi4tTXQ3KWufMvjWw6LGX6uSOMYqtTpJkNgE2vuKVNObob/ScT+zcgBnHKxzlADrDAaysPf87FZBL7IkSeyWPg1Q20GXROZJvV1n31ql6q6TNJuYUtnM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770037049; c=relaxed/simple; bh=Oz7cSlpWv2rTvsEtR1ob+H0tSzf3EinZBNAWl+72ZnI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=A21Ygaf5KNr3W37rrwInQrrVYQetFqhXIC55EeasbCkjJJ1fsvU8va1Rp/BHCDbfbime38X7p2p2nbUZ7JChuDO2sYhLVYxv8pJWHUbprHMD5jc75W3iaLfgUMZwuNr2F4rmAYrV62yZjS5pyPaF/cSKz/KrFaH6DpwVt6521IY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kmahWpII; arc=none smtp.client-ip=209.85.208.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kmahWpII" Received: by mail-lj1-f193.google.com with SMTP id 38308e7fff4ca-385c2112ae5so1357131fa.3 for ; Mon, 02 Feb 2026 04:57:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770037046; x=1770641846; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=4qwYyMOQT9qf7oY7jtB+Qe9HHFdlKNBAoMbngEsefKQ=; b=kmahWpIITVMbo/f50X+4DjRB0uDtOIzgbwVVmphvUYe1c2UN4aqO1ZDokEqNZmYkb7 m2+WrCemepTZ7td1UNXGcVNCluv12OWRAZ46SRs57se7YrYcPN+8UWRWxnuO8tkZzxg8 CMwyE9kpZ3z9WJvRuRRmPCO4k82uIx5ZijDumDIWuNT3nvj2K8a/3bKVK6Ijks8vNpN9 TkxPgH9LL0gM3Hg8PB+En7bIsppx7f500K25C24fXi9+jRab8hr5Ny1vRRv2ngqsCVXI VOEy4a9k81b30kdeFqAUjWOBXzl3jJnIejbJ+uiB85w22P8rQyqnh/5vgb4TLgLr+/N2 fZOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770037046; x=1770641846; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4qwYyMOQT9qf7oY7jtB+Qe9HHFdlKNBAoMbngEsefKQ=; b=KkwJJkU3V3akdrSKwdrjv9atgDc5RbQEEnK3li2T91WS3GtBi+xEF8o3VJyC5os4tb Ms+eNatRGYZ5MAWbIpV7uUHPi3GI/fD2QYTLe4XAsgotNrmDosuxJ7tzZmHbIT36LTN3 x/P7N7alil9CZNeZbZcRxE70kwXQFl9cqnWs+bJftM7ez2ZgeUTpPClpaOjQOOrsNrv6 RXsGYCSCoOUb6/h6dDqcfbqGMVOu/Mr32NYKsTyhh+Rk8HCfTWkZEuu5waFcMQmVjAC8 Un2glRjgiGHgQite5/CTJ5vWC96/u+30C7f/ZamYgHPQ++h2LknNojmx3YYw1/7U3lag PPqA== X-Forwarded-Encrypted: i=1; AJvYcCUPYJ5vSDxiNg7nY2ftopMqny6COUdo1aVJHWIgs79QZ9p4FIrbaJpS0+ugM3TWuDIRQ73prM+2maYn0WM=@vger.kernel.org X-Gm-Message-State: AOJu0YxejHk7OgC2uvMtl8hwAKfmZuJkBzdCRpbc3Q1KbzF+2upzt5k8 Ie6Wo3bPfPXOD4bU4UChwZKNfP5It1lBlXBjZlN0s9qQnYa+JD9126xRXfNT+mb5 X-Gm-Gg: AZuq6aImOg5dloEe7cvbxUc3QAxU8pi7o0qAKvSe6+KhI6HJpP6XH2C0oLJUHR84Hs+ w6pHYAXDrkhO9ucqejv+hH/ZfpYy2btsXp28jtEGioiuSaeiZ5Pkby8lpsJtLYHKX07LPNnZyR4 WYIErUilbLhhw8H7CPM8/gRqy69pqWsLhQDQr9DBQWr/CcEfOTKeMLO85H44iSj8DzeyzwFP6OJ LywUgE/8SsMbPOAnFfpecLMyVQ6f4caZyK+2NsyW1ICdmisQxR/vk55U1Q4mcizhfF9VTxIjFvC +7lbHvzWax7N2RdB17riwVbpDuyyVBP3257Yq6FWiEr2QFRO/wqpL8XkJalvIX+UTvAu777f9Sm J2KSE9n+SNlCokQTmEr5Qx83iYeLQL1Vncr8STTTVbf+C/J4EpCL17JBmp84L/NS3fDJhGiO4rN jkBMk= X-Received: by 2002:a05:600c:3541:b0:47d:4fbe:e6de with SMTP id 5b1f17b1804b1-482db4ac12dmr88549885e9.6.1770030948249; Mon, 02 Feb 2026 03:15:48 -0800 (PST) Received: from skbuf ([2a02:2f04:d501:d900:74c4:3a65:f9a9:6c29]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-435e1354114sm45572421f8f.42.2026.02.02.03.15.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Feb 2026 03:15:47 -0800 (PST) Date: Mon, 2 Feb 2026 13:15:44 +0200 From: Vladimir Oltean To: Daniel Golle Cc: Jakub Kicinski , lxu@maxlinear.com, hkallweit1@gmail.com, yweng@maxlinear.com, ajayaraman@maxlinear.com, andrew@lunn.ch, netdev@vger.kernel.org, bxu@maxlinear.com, krzk+dt@kernel.org, linux-kernel@vger.kernel.org, lrosu@maxlinear.com, chad@monroe.io, conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org, edumazet@google.com, pabeni@redhat.com, cezary.wilmanski@adtran.com, davem@davemloft.net, john@phrozen.org, frankwu@gmx.de, jpovazanec@maxlinear.com, linux@armlinux.org.uk, fchan@maxlinear.com, horms@kernel.org Subject: Re: [net-next,v11,4/4] net: dsa: add basic initial driver for MxL862xx switches Message-ID: <20260202111544.r2mlklwdvviqq7q3@skbuf> References: <46226b74030f76bd04149ed5c92b3e263abbe6c2.1769817939.git.daniel@makrotopia.org> <20260131175243.1122906-2-kuba@kernel.org> <20260202094405.rsojaz5xmorubjfz@skbuf> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Feb 02, 2026 at 10:49:47AM +0000, Daniel Golle wrote: > > > The dsa_to_port() function can return NULL if the port is not found in > > > the switch tree. The code stores the result in dp but doesn't check if > > > dp is NULL before dereferencing dp->cpu_dp->index. > > > > > > Looking at include/net/dsa.h, dsa_to_port() returns NULL when the port > > > is not found: > > > > > > static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p) > > > { > > > struct dsa_switch_tree *dst = ds->dst; > > > struct dsa_port *dp; > > > > > > list_for_each_entry(dp, &dst->ports, list) > > > if (dp->ds == ds && dp->index == p) > > > return dp; > > > > > > return NULL; > > > } > > > > > > Additionally, even if dp is non-NULL, dp->cpu_dp could also be NULL if > > > the CPU port hasn't been properly assigned during initialization. > > > > mxl862xx_add_single_port_bridge() has been called when all other port > > types except user ports have been excluded. All user and DSA ports have > > a non-NULL dp->cpu_dp pointer after dsa_tree_setup_cpu_ports() runs, > > i.e. also at the time of ds->ops->port_setup(). > > here, as well as in mxl862xx_setup_cpu_bridge(), right? Yeah. If you think adding a comment helps keep spirits calm, you can also do that. > > Technically ds->ops->setup() runs under dsa2_mutex, but the "static int idx" > > is still not ideal due to the ever-increasing index upon unbinding and > > rebinding. > > As mentioned in my reply to Jakub[1] many drivers follow this pattern and it would > imho be a good idea to agree on a convention or even provide a helper function > which names the MII bus for DSA drivers. What do you think? > > [1]: https://patchwork.kernel.org/comment/26768088/ I don't really have an opinion, the internal MDIO bus is part of each driver's housekeeping, and DSA tries to stay out of that as much as possible. Maybe PHY maintainers may know more what user space tooling may break if the mii_bus->id gets changed, or may prefer a naming convention irrespective of the bus being part of a DSA switch or not.