Thread (21 messages) flat view 21 messages, 4 authors, 2024-06-20

Re: [PATCH v5 net-next 1/7] net: move ethtool-related netdev state into its own struct

From: Jakub Kicinski <kuba@kernel.org>
Date: 2024-06-18 23:43:09

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 :)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help