summaryrefslogtreecommitdiff
path: root/drivers/i2c/busses/i2c-aspeed.c
diff options
context:
space:
mode:
authorBrendan Higgins <brendanhiggins@google.com>2017-07-29 04:00:12 +0300
committerWolfram Sang <wsa@the-dreams.de>2017-08-14 23:08:13 +0300
commitf1c0b7e448b9e66dd9a7343bab58a3d3a477e104 (patch)
treececbf06006c6d959de29bd75387e4023b58fffa5 /drivers/i2c/busses/i2c-aspeed.c
parent42543aeb48e3701b49e0a83654248afc38feb88f (diff)
downloadlinux-f1c0b7e448b9e66dd9a7343bab58a3d3a477e104.tar.xz
i2c: aspeed: fixed potential null pointer dereference
Before I skipped null checks when the master is in the STOP state; this fixes that. Signed-off-by: Brendan Higgins <brendanhiggins@google.com> Acked-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Fixes: f327c686d3ba ("i2c: aspeed: added driver for Aspeed I2C")
Diffstat (limited to 'drivers/i2c/busses/i2c-aspeed.c')
-rw-r--r--drivers/i2c/busses/i2c-aspeed.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
index f19348328a71..6fdf9231c23c 100644
--- a/drivers/i2c/busses/i2c-aspeed.c
+++ b/drivers/i2c/busses/i2c-aspeed.c
@@ -410,10 +410,11 @@ static bool aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus)
}
/* We are in an invalid state; reset bus to a known state. */
- if (!bus->msgs && bus->master_state != ASPEED_I2C_MASTER_STOP) {
+ if (!bus->msgs) {
dev_err(bus->dev, "bus in unknown state");
bus->cmd_err = -EIO;
- aspeed_i2c_do_stop(bus);
+ if (bus->master_state != ASPEED_I2C_MASTER_STOP)
+ aspeed_i2c_do_stop(bus);
goto out_no_complete;
}
msg = &bus->msgs[bus->msgs_index];