summaryrefslogtreecommitdiffstats
path: root/resources/libreboot/patch/kgpe-d16/0143-device-smbus-Avoid-infinite-loop-if-i2c-device-has-w.patch
blob: bf9c82912d92e537e3e92d53eb967ae39c8ef6aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
From 54ef1e4efe549e310b29258fe9c2efcc367ae942 Mon Sep 17 00:00:00 2001
From: Timothy Pearson <tpearson@raptorengineeringinc.com>
Date: Thu, 22 Oct 2015 17:19:19 -0500
Subject: [PATCH 143/143] device/smbus: Avoid infinite loop if i2c device has
 wrong parent

Change-Id: I4c615f3c5b3908178b8223cb6620c393bbfb4e7f
Signed-off-by: Timothy Pearson <tpearson@raptorengineeringinc.com>
---
 src/device/smbus_ops.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/device/smbus_ops.c b/src/device/smbus_ops.c
index 184a06a..f4b1355 100644
--- a/src/device/smbus_ops.c
+++ b/src/device/smbus_ops.c
@@ -29,8 +29,17 @@ struct bus *get_pbus_smbus(device_t dev)
 {
 	struct bus *pbus = dev->bus;
 
-	while (pbus && pbus->dev && !ops_smbus_bus(pbus))
-		pbus = pbus->dev->bus;
+	while (pbus && pbus->dev && !ops_smbus_bus(pbus)) {
+		if (pbus->dev->bus != pbus) {
+			pbus = pbus->dev->bus;
+		}
+		else {
+			printk(BIOS_WARNING,
+				"%s Find SMBus bus operations: unable to proceed\n",
+				dev_path(dev));
+			break;
+		}
+	}
 
 	if (!pbus || !pbus->dev || !pbus->dev->ops
 	    || !pbus->dev->ops->ops_smbus_bus) {
-- 
1.7.9.5