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>
This commit is contained in:
Matt DeVillier 2022-06-18 15:22:47 -05:00 committed by Felix Held
parent f887879815
commit 06abb91b22
1 changed files with 1 additions and 1 deletions

View File

@ -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;