⬢ DragonFlyBSD Kernel Audit
DF-4983 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/video/cxm/cxm.c
+++ b/sys/dev/video/cxm/cxm.c
@@ -2112,10 +2112,15 @@ cxm_write_ivar(device_t dev, device_t child, int index, uintptr_t val)
 	case CXM_IVAR_BTAG:
 		return EINVAL;

 	case CXM_IVAR_IICBUS:
-		if (sc->iicbus)
-			return EINVAL;
-		sc->iicbus = val ? *(device_t *)val : NULL;
+		if (val == 0) {
+			/* detach-time invalidation from cxm_iic_detach() */
+			sc->iicbus = NULL;
+		} else {
+			if (sc->iicbus)
+				return EINVAL;
+			sc->iicbus = *(device_t *)val;
+		}
 		break;

 	default:
 		return ENOENT;
 	}