i2c: aspeed: fixed potential null pointer dereference
PATCH 1/1 i2c: aspeed: fixed potential null pointer dereference
Before I skipped null checks when the master is in the STOP state; this fixes that.
--- drivers/i2c/busses/i2c-aspeed.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-aspeed.c +3 -2
@@ -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];
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
Quoted 4 lines · Brendan Higgins
Before I skipped null checks when the master is in the STOP state; this fixes that.
Signed-off-by Brendan Higgins <[email protected]>
Out of interest, was this found by code review, or did you hit this in testing?
Cheers,
Joel
Quoted 25 lines
--- drivers/i2c/busses/i2c-aspeed.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-aspeed.c +3
-3@@ -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]; --2.14.0.rc0.400.g1c36432dff-goog
Quoted 10 lines · Joel Stanley
Quoted 4 lines · Brendan Higgins
Before I skipped null checks when the master is in the STOP state; this fixes that.
Signed-off-by Brendan Higgins <[email protected]>Acked-by Joel Stanley <[email protected]>Out of interest, was this found by code review, or did you hit this in testing?
I am pretty sure we hit it in testing. Unfortunately, we had trouble reproducing it, but we did see a null pointer dereference.
Quoted 4 lines
Cheers,
Joel
Joel Stanley
maintainer[dropping upstream cc]
Quoted 6 lines · Brendan Higgins
Quoted 5 lines · Joel Stanley
Quoted 3 lines · Brendan Higgins
Before I skipped null checks when the master is in the STOP state; this fixes that.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Brendan Higgins <[email protected]>Acked-by Joel Stanley <[email protected]>Out of interest, was this found by code review, or did you hit this in testing?
I am pretty sure we hit it in testing. Unfortunately, we had trouble reproducing it, but we did see a null pointer dereference.
Thanks. I've applied it to the openbmc dev-4.10 tree as well.
Cheers,
Joel
Quoted 4 lines · Brendan Higgins
Before I skipped null checks when the master is in the STOP state; this fixes that.
Signed-off-by Brendan Higgins <[email protected]>
Is there a suitable "Fixes:" tag for this?
Joel Stanley
maintainerQuoted 8 lines · Wolfram Sang
Quoted 4 lines · Brendan Higgins
Before I skipped null checks when the master is in the STOP state; this fixes that.
Signed-off-by Brendan Higgins <[email protected]>Is there a suitable "Fixes:" tag for this?
The driver was introduced in 4.13, so we could add:
Cheers,
Joel
Wolfram Sang
AppliedQuoted 4 lines · Brendan Higgins
Before I skipped null checks when the master is in the STOP state; this fixes that.
Signed-off-by Brendan Higgins <[email protected]>
Applied to for-current, thanks!