DragonFlyBSD Kernel Audit
DF-1540 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/netif/mn/if_mn.c b/sys/dev/netif/mn/if_mn.c
--- a/sys/dev/netif/mn/if_mn.c
+++ b/sys/dev/netif/mn/if_mn.c
@@ -756,6 +756,14 @@
 	if (sch->state == DOWN)
 		return (0);
 	sch->state = DOWN;
+	/*
+	 * DF-1540: ngmn_disconnect sets sch->state = DOWN but never
+	 * cleared sch->hook.  Once Netgraph frees hook (kfree(hook->name)
+	 * + kfree(hook) on return), NGM_TEXT_STATUS at line 407 derefs
+	 * sch->hook->name -- a dangling pointer.  Clear it so the status
+	 * handler stops trying to print this channel.
+	 */
+	sch->hook = NULL;
 
 	/* Set receiver & transmitter off */
 	sc->m32_mem.cs[chan].flags = 0x80920006;