[RFC PATCH 1/2] net: dsa: return early if there is no master

Michael Walle michael at walle.cc
Tue Feb 23 21:05:46 CET 2021


> 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


More information about the U-Boot mailing list