Skip to content

Commit b5e1871

Browse files
author
Izabela Bakollari
committed
net: free_netdev: exit earlier if dummy
JIRA: https://issues.redhat.com/browse/RHEL-59092 commit f8d0567 Author: Breno Leitao <leitao@debian.org> Date: Mon Apr 22 05:38:55 2024 -0700 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@kernel.org> Signed-off-by: Breno Leitao <leitao@debian.org> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Izabela Bakollari <ibakolla@redhat.com>
1 parent 823c8fa commit b5e1871

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/core/dev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10765,7 +10765,8 @@ void free_netdev(struct net_device *dev)
1076510765
dev->xdp_bulkq = NULL;
1076610766

1076710767
/* Compatibility with error handling in drivers */
10768-
if (dev->reg_state == NETREG_UNINITIALIZED) {
10768+
if (dev->reg_state == NETREG_UNINITIALIZED ||
10769+
dev->reg_state == NETREG_DUMMY) {
1076910770
netdev_freemem(dev);
1077010771
return;
1077110772
}

0 commit comments

Comments
 (0)