From 0e82c7635997a11dbcfa98835c179084447ae2b0 Mon Sep 17 00:00:00 2001 From: pravin shelar Date: Fri, 28 Oct 2016 16:01:41 -0700 Subject: [PATCH] genetlink: Fix generic netlink family unregister This patch fixes a typo in unregister operation. Following crash is fixed by this patch. It can be easily reproduced by repeating modprobe and rmmod module that uses genetlink. [ 261.446686] BUG: unable to handle kernel paging request at ffffffffa0264088 [ 261.448921] IP: [] strcmp+0xe/0x30 [ 261.450494] PGD 1c09067 [ 261.451266] PUD 1c0a063 [ 261.452091] PMD 8068d5067 [ 261.452525] PTE 0 [ 261.453164] [ 261.453618] Oops: 0000 [#1] SMP [ 261.454577] Modules linked in: openvswitch(+) ... [ 261.480753] RIP: 0010:[] [] strcmp+0xe/0x30 [ 261.483069] RSP: 0018:ffffc90003c0bc28 EFLAGS: 00010282 [ 261.510145] Call Trace: [ 261.510896] [] genl_family_find_byname+0x5a/0x70 [ 261.512819] [] genl_register_family+0xb9/0x630 [ 261.514805] [] dp_init+0xbc/0x120 [openvswitch] [ 261.518268] [] do_one_initcall+0x3d/0x160 [ 261.525041] [] do_init_module+0x60/0x1f1 [ 261.526754] [] load_module+0x22af/0x2860 [ 261.530144] [] SYSC_finit_module+0x96/0xd0 [ 261.531901] [] SyS_finit_module+0xe/0x10 [ 261.533605] [] do_syscall_64+0x6e/0x180 [ 261.535284] [] entry_SYSCALL64_slow_path+0x25/0x25 [ 261.546512] RIP [] strcmp+0xe/0x30 [ 261.550198] ---[ end trace 76505a814dd68770 ]--- Fixes: 2ae0f17df1c ("genetlink: use idr to track families"). Reported-by: Jarno Rajahalme CC: Johannes Berg Signed-off-by: Pravin B Shelar Reviewed-by: Johannes Berg Signed-off-by: David S. Miller --- net/netlink/genetlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index df0cbcd..caf04d7 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c @@ -399,7 +399,7 @@ int genl_unregister_family(const struct genl_family *family) { genl_lock_all(); - if (genl_family_find_byid(family->id)) { + if (!genl_family_find_byid(family->id)) { genl_unlock_all(); return -ENOENT; } -- 2.7.4