⬢ DragonFlyBSD Kernel Audit
DF-4961 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/drm/amd/amdgpu/amdgpu_i2c.c
+++ b/sys/dev/drm/amd/amdgpu/amdgpu_i2c.c
@@ -205,6 +205,16 @@
 		i2c->bit.timeout = usecs_to_jiffies(2200);	/* from VESA */
 		i2c->bit.data = i2c;
 		ret = i2c_bit_add_bus(&i2c->adapter);
+#ifdef __DragonFly__
+		/*
+		 * DF's i2c_bit_add_bus() does not call i2c_add_adapter()
+		 * like upstream Linux does, so lock_ops would stay NULL and
+		 * i2c_transfer() would call adapter->lock_ops->lock_bus()
+		 * through a NULL pointer (linux_i2c.c:99).  Mirrors the
+		 * radeon bit branch (radeon_i2c.c:970-972).
+		 */
+		i2c_add_adapter(&i2c->adapter);
+#endif
 		if (ret) {
 			DRM_ERROR("Failed to register bit i2c %s\n", name);
 			goto out_free;