[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240422123921.854943-3-leitao@debian.org>
Date: Mon, 22 Apr 2024 05:38:55 -0700
From: Breno Leitao <leitao@...ian.org>
To: aleksander.lobakin@...el.com,
kuba@...nel.org,
davem@...emloft.net,
pabeni@...hat.com,
edumazet@...gle.com,
elder@...nel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org,
nbd@....name,
sean.wang@...iatek.com,
Mark-MC.Lee@...iatek.com,
lorenzo@...nel.org,
taras.chornyi@...ision.eu,
ath11k@...ts.infradead.org,
ath10k@...ts.infradead.org,
linux-wireless@...r.kernel.org,
geomatsi@...il.com,
kvalo@...nel.org
Cc: quic_jjohnson@...cinc.com,
leon@...nel.org,
dennis.dalessandro@...nelisnetworks.com,
linux-kernel@...r.kernel.org,
netdev@...r.kernel.org,
bpf@...r.kernel.org,
idosch@...sch.org,
leitao@...ian.org,
angelogioacchino.delregno@...labora.com,
matthias.bgg@...il.com,
Ido Schimmel <idosch@...dia.com>,
Jiri Pirko <jiri@...nulli.us>,
Simon Horman <horms@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Subject: [PATCH net-next v7 02/10] net: free_netdev: exit earlier if dummy
For dummy devices, exit earlier at free_netdev() instead of executing
the whole function. This is necessary, because dummy devices are
special, and shouldn't have the second part of the function executed.
Otherwise reg_state, which is NETREG_DUMMY, will be overwritten and
there will be no way to identify that this is a dummy device. Also, this
device do not need the final put_device(), since dummy devices are not
registered (through register_netdevice()), where the device reference is
increased (at netdev_register_kobject()/device_add()).
Suggested-by: Jakub Kicinski <kuba@...nel.org>
Signed-off-by: Breno Leitao <leitao@...ian.org>
Reviewed-by: Ido Schimmel <idosch@...dia.com>
---
net/core/dev.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 44c2d698fd1b..62b39d6b1d8f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -11066,7 +11066,8 @@ void free_netdev(struct net_device *dev)
phy_link_topo_destroy(dev->link_topo);
/* Compatibility with error handling in drivers */
- if (dev->reg_state == NETREG_UNINITIALIZED) {
+ if (dev->reg_state == NETREG_UNINITIALIZED ||
+ dev->reg_state == NETREG_DUMMY) {
netdev_freemem(dev);
return;
}
--
2.43.0
Powered by blists - more mailing lists