diff mbox series

[net-next,2/2] net: initialize netdev->lock on dummy devices

Message ID 20250111065955.3698801-2-kuba@kernel.org (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series [net-next,1/2] net: un-export init_dummy_netdev() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 6 this patch: 6
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 79 this patch: 79
netdev/source_inline success Was 0 now: 0
netdev/contest pending net-next-2025-01-11--09-00 (tests: 0)

Commit Message

Jakub Kicinski Jan. 11, 2025, 6:59 a.m. UTC
Make sure netdev->lock is always valid, even on dummy netdevs.

Apparently it's legal to call mutex_destroy() on an uninitialized
mutex (and we do that in free_netdev()), but it doesn't seem right.
Plus we'll soon want to take netdev->lock on more paths which dummy
netdevs may reach.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 net/core/dev.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/net/core/dev.c b/net/core/dev.c
index 23e7f6a3925b..00552197d601 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10756,6 +10756,8 @@  static void init_dummy_netdev_core(struct net_device *dev)
 	/* napi_busy_loop stats accounting wants this */
 	dev_net_set(dev, &init_net);
 
+	mutex_init(&dev->lock);
+
 	/* Note : We dont allocate pcpu_refcnt for dummy devices,
 	 * because users of this 'device' dont need to change
 	 * its refcount.