DragonFlyBSD Kernel Audit
DF-1295 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/video/cxm/cxm.c b/sys/dev/video/cxm/cxm.c
--- a/sys/dev/video/cxm/cxm.c
+++ b/sys/dev/video/cxm/cxm.c
@@ -2194,7 +2194,10 @@
 	sc->enc_pool.read = 0;
 	sc->enc_pool.write = 0;
 
-	sc->enc_proc = NULL;
+	if (sc->enc_proc != NULL) {
+		PRELE(sc->enc_proc);
+		sc->enc_proc = NULL;
+	}
 	sc->enc_signal = 0;
 
 	device_unbusy(devclass_get_device(cxm_devclass, unit));
@@ -2757,7 +2760,11 @@
 			sig = 0;
 
 		crit_enter();
+		if (sc->enc_proc != NULL && sc->enc_proc != curproc)
+			PRELE(sc->enc_proc);
 		sc->enc_proc = sig ? curproc : NULL;
+		if (sig)
+			PHOLD(curproc);
 		sc->enc_signal = sig;
 		crit_exit();
 		break;