[PATCH 6/8] i2c: nomadik: handle pm_runtime errors
Dmitry Guzman
Dmitry.Guzman at mobileye.com
Tue Nov 3 00:29:42 PST 2026
In nmk_i2c_xfer(), pm_runtime_get_sync() is called on start and then
the controller registers are accessed without checking the return value.
If pm_runtime_get_sync() fails, access to the register of the device that
was not correctly powered on may cause a bus fault or other unpredictable
system behavior.
Check the return value of pm_runtime_get_sync() and it if is not 0,
return the error immediately.
Signed-off-by: Dmitry Guzman <Dmitry.Guzman at mobileye.com>
---
drivers/i2c/busses/i2c-nomadik.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index d07246d11b35..361a5fc6a587 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -734,7 +734,9 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
int i;
struct nmk_i2c_dev *priv = i2c_get_adapdata(i2c_adap);
- pm_runtime_get_sync(&priv->adev->dev);
+ i = pm_runtime_get_sync(&priv->adev->dev);
+ if (i)
+ return i;
/* setup the i2c controller */
setup_i2c_controller(priv);
--
2.43.0
More information about the linux-arm-kernel
mailing list