diff options
author | Nico Huber <nico.h@gmx.de> | 2022-08-01 20:23:13 +0200 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-08-03 20:55:14 +0000 |
commit | ee443c8d3e7cf6edbc20c6a2322df31001ff84c7 (patch) | |
tree | 2aaa9e975ebb55c2621d1e445da2521e059c549b /src | |
parent | 51a35764b31d987b624c60dab7a86b355998a184 (diff) |
drivers/i2c/dw_i2c: Re-add check for empty i2c transfer list
The check was recently removed to allow callers to pass `count == 0`.
Dereferencing the `msg` array is invalid in that case, though. Linux,
where we borrowed the i2c interface from, also treats this with -EINVAL.
Change-Id: I1eec02dd3a3fcf2d477a62cc65292fca40e469d3
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/66341
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-by: Tim Crawford <tcrawford@system76.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/drivers/i2c/designware/dw_i2c.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/drivers/i2c/designware/dw_i2c.c b/src/drivers/i2c/designware/dw_i2c.c index fdedf63b56..ecd9e88698 100644 --- a/src/drivers/i2c/designware/dw_i2c.c +++ b/src/drivers/i2c/designware/dw_i2c.c @@ -467,7 +467,7 @@ static enum cb_err dw_i2c_transfer(unsigned int bus, const struct i2c_msg *msg, size_t start; uint16_t addr; - if (!msg) + if (count == 0 || !msg) return -1; /* Break up the transfers at the differing slave address boundary. */ |