On Tue, 18 Jun 2024 16:05:13 -0700 David Wei wrote:
quoted
@@ -11065,6 +11065,9 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
dev->real_num_rx_queues = rxqs;
if (netif_alloc_rx_queues(dev))
goto free_all;
+ dev->ethtool = kzalloc(sizeof(*dev->ethtool), GFP_KERNEL_ACCOUNT);
Why GFP_KERNEL_ACCOUNT instead of just GFP_KERNEL?
netdevs can be created by a user, think veth getting created in
a container. So we need to account the allocated memory towards
the memory limit of the current user.
quoted
+ if (!dev->ethtool)
+ goto free_all;
strcpy(dev->name, name);
dev->name_assign_type = name_assign_type;
@@ -11115,6 +11118,7 @@ void free_netdev(struct net_device *dev)
return;
}
+ kfree(dev->ethtool);
dev->ethtool = NULL?
defensive programming is sometimes permitted by not encouraged :)