⬢ DragonFlyBSD Kernel Audit
DF-5356 / fix.diff
← back to finding ↓ download raw
--- a/sys/bus/pccard/pccard.c
+++ b/sys/bus/pccard/pccard.c
@@ -184,6 +184,16 @@
 	int i;
 
 	/*
+	 * Card-detect bounce can re-run the bridge insert path while the
+	 * card is (again) reported present.  Attaching over a live card
+	 * orphans the previous function list (permanent leak) and stacks
+	 * duplicate children, so refuse; the removal path empties the
+	 * list, making it the "no card attached" marker.
+	 */
+	if (!STAILQ_EMPTY(&sc->card.pf_head))
+		return (EBUSY);
+
+	/*
 	 * this is here so that when socket_enable calls gettype, trt happens
 	 */
 	STAILQ_INIT(&sc->card.pf_head);