Dan Carpenter <dan.carpenter@xxxxxxxxxx> ezt írta (időpont: 2022. okt. 14., P, 9:03): > > > drivers/i2c/busses/i2c-cp2615.c | 2 ++ > > > 1 file changed, 2 insertions(+) > > > > > > diff --git a/drivers/i2c/busses/i2c-cp2615.c b/drivers/i2c/busses/i2c-cp2615.c > > > index 3ded28632e4c..ad1d6e548503 100644 > > > --- a/drivers/i2c/busses/i2c-cp2615.c > > > +++ b/drivers/i2c/busses/i2c-cp2615.c > > > @@ -231,6 +231,8 @@ cp2615_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) > > > } else { > > > i2c_w.read_len = 0; > > > i2c_w.write_len = msg->len; > > > + if (msg->len > sizeof(i2c_w.data)) > > > + return -EINVAL; > > > > Please move this up to line 225, as an invalid `read_len` is also an > > error and should bail out accordingly. > > > > I don't see the bug. Is that something that requires knowledge of the > hardware? No, what I mean is that you put the check in the else clause of > if (msg->flags & I2C_M_RD) { But a `msg->len > MAX_I2C_SIZE` is invalid, regardless of `msg->flags`. So the check should be outside if the `if`. > regards, > dan carpenter Bence