Unverified Commit f91609f4 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!5062 team: fix null-ptr-deref when team device type is changed

parents a32a9e4a 152bb1d4
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -2122,6 +2122,11 @@ static const struct ethtool_ops team_ethtool_ops = {
static void team_setup_by_port(struct net_device *dev,
			       struct net_device *port_dev)
{
	struct team *team = netdev_priv(dev);

	if (port_dev->type == ARPHRD_ETHER)
		dev->header_ops	= team->header_ops_cache;
	else
		dev->header_ops	= port_dev->header_ops;
	dev->type = port_dev->type;
	dev->hard_header_len = port_dev->hard_header_len;
@@ -2169,8 +2174,11 @@ static int team_dev_type_check_change(struct net_device *dev,

static void team_setup(struct net_device *dev)
{
	struct team *team = netdev_priv(dev);

	ether_setup(dev);
	dev->max_mtu = ETH_MAX_MTU;
	team->header_ops_cache = dev->header_ops;

	dev->netdev_ops = &team_netdev_ops;
	dev->ethtool_ops = &team_ethtool_ops;
+2 −0
Original line number Diff line number Diff line
@@ -189,6 +189,8 @@ struct team {
	struct net_device *dev; /* associated netdevice */
	struct team_pcpu_stats __percpu *pcpu_stats;

	const struct header_ops *header_ops_cache;

	struct mutex lock; /* used for overall locking, e.g. port lists write */

	/*