Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1699199 > unrolled thread

[PATCH v1] i2c: aspeed: fixed potential null pointer dereference

Started byBrendan Higgins <brendanhiggins@google.com>
First post2017-07-29 03:10 +0200
Last post2017-07-31 11:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v1] i2c: aspeed: fixed potential null pointer dereference Brendan Higgins <brendanhiggins@google.com> - 2017-07-29 03:10 +0200
    Re: [PATCH v1] i2c: aspeed: fixed potential null pointer dereference Joel Stanley <joel@jms.id.au> - 2017-07-31 11:30 +0200

#1699199 — [PATCH v1] i2c: aspeed: fixed potential null pointer dereference

FromBrendan Higgins <brendanhiggins@google.com>
Date2017-07-29 03:10 +0200
Subject[PATCH v1] i2c: aspeed: fixed potential null pointer dereference
Message-ID<u8oqu-3ee-11@gated-at.bofh.it>
Before I skipped null checks when the master is in the STOP state; this
fixes that.

Signed-off-by: Brendan Higgins <brendanhiggins@google.com>
---
 drivers/i2c/busses/i2c-aspeed.c | 5 +++--
 1 file 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];
-- 
2.14.0.rc0.400.g1c36432dff-goog

[toc] | [next] | [standalone]


#1699852

FromJoel Stanley <joel@jms.id.au>
Date2017-07-31 11:30 +0200
Message-ID<u9fbs-4uw-9@gated-at.bofh.it>
In reply to#1699199
On Sat, Jul 29, 2017 at 10:30 AM, Brendan Higgins
<brendanhiggins@google.com> wrote:
> 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>

Out of interest, was this found by code review, or did you hit this in testing?

Cheers,

Joel

> ---
>  drivers/i2c/busses/i2c-aspeed.c | 5 +++--
>  1 file 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];
> --
> 2.14.0.rc0.400.g1c36432dff-goog
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web