device/i2c_bus: Check for self loop in bus link

When trying to find the parent i2c bus of a given device, ensure that
the bus link doesn't point to itself, else we'll get stuck in an
infinite loop.

Change-Id: I56cb6b2a3e4f98d2ce3ef2d8298e74d52661331c
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/65229
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
diff --git a/src/device/i2c_bus.c b/src/device/i2c_bus.c
index c355506..df36404 100644
--- a/src/device/i2c_bus.c
+++ b/src/device/i2c_bus.c
@@ -25,7 +25,7 @@
 		    (parent->ops->ops_i2c_bus || parent->ops->ops_smbus_bus))
 			break;
 
-		if (parent && parent->bus)
+		if (parent && parent->bus && link != parent->bus)
 			link = parent->bus;
 		else
 			link = NULL;