From ee443c8d3e7cf6edbc20c6a2322df31001ff84c7 Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Mon, 1 Aug 2022 20:23:13 +0200 Subject: 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/66341 Tested-by: build bot (Jenkins) Reviewed-by: Matt DeVillier Reviewed-by: Tim Crawford --- src/drivers/i2c/designware/dw_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/drivers/i2c') 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. */ -- cgit v1.2.3