drivers: i2c_nrfx_twim: correct concat buf bounds check
The original checked only the current message length against the buffer size, not accounting for space already used. Also improve the diagnostic to indicate how much space is required vs given. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
be8c59b4a4
commit
d719801d1e
1 changed files with 3 additions and 2 deletions
|
@ -75,8 +75,9 @@ static int i2c_nrfx_twim_transfer(struct device *dev, struct i2c_msg *msgs,
|
|||
!= (msgs[i].flags & I2C_MSG_READ)));
|
||||
|
||||
if ((concat_len != 0) || !last_or_non_concatenable) {
|
||||
if (msgs[i].len > concat_buf_size) {
|
||||
LOG_ERR("Concatenation buffer is too small");
|
||||
if ((concat_len + msgs[i].len) > concat_buf_size) {
|
||||
LOG_ERR("concat-buf overflow: %u + %u > %u",
|
||||
concat_len, msgs[i].len, concat_buf_size);
|
||||
return -ENOSPC;
|
||||
}
|
||||
if (!(msgs[i].flags & I2C_MSG_READ)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue