From: Michael Walle Date: Tue, 23 Feb 2021 21:05:46 +0100 Subject: [RFC PATCH 1/2] net: dsa: return early if there is no master In-Reply-To: <20210223163251.ncufz5qlcxlndojv@skbuf> References: <20210223161906.9177-1-michael@walle.cc> <20210223161906.9177-2-michael@walle.cc> <20210223163251.ncufz5qlcxlndojv@skbuf> Message-ID: <50747491e458ff64a8b8b38de329ed26@walle.cc> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de > I think you can also be more aggressive and remove the checks: > > if (!master) > return -EINVAL; > > from dsa_port_send and dsa_port_recv. At least it sounds broken to me > that this could ever happen. The following comment got me curious: /* * stop master only if it's active, don't probe it otherwise. * Under normal usage it would be active because we're using it, but * during tear-down it may have been removed ahead of us. */ if (master && device_active(master)) eth_get_ops(master)->stop(master); Do we actually care about device removal? I don't think it will work right now. If you do "unbind eth 0" and then using a DSA port you'll get a panic. The check for master doesn't really help here because it will return "priv->master_dev" which is just set in .pre_probe(). Thus in the error case, it will contain a dangling pointer. -michael