[PATCH net-next 03/10] net: sparx5: add hostmode with phylink support

Jakub Kicinski kuba at kernel.org
Fri Apr 16 22:22:44 BST 2021


On Fri, 16 Apr 2021 15:16:50 +0200 Steen Hegelund wrote:
> +static int sparx5_set_mac_address(struct net_device *dev, void *p)
> +{
> +	const struct sockaddr *addr = p;
> +
> +	/* Record the address */
> +	ether_addr_copy(dev->dev_addr, addr->sa_data);

I think you need to validate that add is a valid ethernet address.
is_valid_ether_addr()

> +struct net_device *sparx5_create_netdev(struct sparx5 *sparx5, u32 portno)
> +{
> +	struct sparx5_port *spx5_port;
> +	struct net_device *ndev;
> +	u64 val;
> +
> +	ndev = devm_alloc_etherdev(sparx5->dev, sizeof(struct sparx5_port));
> +	if (!ndev)
> +		return ERR_PTR(-ENOMEM);
> +
> +	SET_NETDEV_DEV(ndev, sparx5->dev);
> +	spx5_port = netdev_priv(ndev);
> +	spx5_port->ndev = ndev;
> +	spx5_port->sparx5 = sparx5;
> +	spx5_port->portno = portno;
> +	sparx5_set_port_ifh(spx5_port->ifh, portno);
> +	snprintf(ndev->name, IFNAMSIZ, "eth%d", portno);

Please don't try to name interfaces in the kernel.



More information about the linux-arm-kernel mailing list