From c3463c7f5d4a80bc8992b6a1f695e49739fbd012 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Tue, 31 May 2016 10:13:13 +0800 Subject: common/i2c: Fix I2C protection for i2c read/write commands i2cread/i2cwrite takes 8-bit addresses, while i2cxfer takes 7-bit addresses, make sure we filter on the correct address. BRANCH=none BUG=chrome-os-partner:52431 TEST=Book elm-rev1 Change-Id: I84dbc8468d7a8401673c90118f5799b3ff75c2e1 Signed-off-by: Nicolas Boichat Reviewed-on: https://chromium-review.googlesource.com/348153 Commit-Ready: Nicolas Boichat Tested-by: Nicolas Boichat Reviewed-by: Randall Spangler --- common/i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/i2c.c b/common/i2c.c index 03d7e2b9c6..51de07dd92 100644 --- a/common/i2c.c +++ b/common/i2c.c @@ -483,7 +483,7 @@ static int i2c_command_read(struct host_cmd_handler_args *args) return EC_RES_INVALID_PARAM; if (port_protected[p->port] && i2c_port->passthru_allowed) { - if (!i2c_port->passthru_allowed(i2c_port, p->addr)) + if (!i2c_port->passthru_allowed(i2c_port, p->addr >> 1)) return EC_RES_ACCESS_DENIED; } @@ -517,7 +517,7 @@ static int i2c_command_write(struct host_cmd_handler_args *args) return EC_RES_INVALID_PARAM; if (port_protected[p->port] && i2c_port->passthru_allowed) { - if (!i2c_port->passthru_allowed(i2c_port, p->addr)) + if (!i2c_port->passthru_allowed(i2c_port, p->addr >> 1)) return EC_RES_ACCESS_DENIED; } -- cgit v1.2.1