From 06abb91b22b5911315e65ad6b287ba51a7f28eac Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Sat, 18 Jun 2022 15:22:47 -0500 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/65229 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Nico Huber --- src/device/i2c_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/device/i2c_bus.c b/src/device/i2c_bus.c index c355506f72..df36404660 100644 --- a/src/device/i2c_bus.c +++ b/src/device/i2c_bus.c @@ -25,7 +25,7 @@ struct bus *i2c_link(const struct device *const dev) (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;