mfd: tps6507x - fix off-by-one value range checking
PATCH 1/1 mfd: tps6507x - fix off-by-one value range checking
We use msg[0] for device register.
If bytes == (TPS6507X_MAX_REGISTER + 1),
we got a buffer overflow when doing memcpy(&msg[1], src, bytes); Thus we must ensure bytes not greater than TPS6507X_MAX_REGISTER.
Signed-off-by Axel Lin <[email protected]>
--- drivers/mfd/tps6507x.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mfd/tps6507x.c +1 -1
@@ -68,7 +68,7 @@ static int tps6507x_i2c_write_device(struct tps6507x_dev *tps6507x, char reg,u8 msg[TPS6507X_MAX_REGISTER +1 ];int ret; -if (bytes > (TPS6507X_MAX_REGISTER +1 )) +if (bytes >TPS6507X_MAX_REGISTER )return -EINVAL ; msg[0 ] = reg;
Signature · 1 line
1.7.2
Hi Axel,
Quoted 4 lines · Axel Lin
We use msg[0] for device register.
If bytes == (TPS6507X_MAX_REGISTER+ 1),
we got a buffer overflow when doingmemcpy(&msg[1], src, bytes); Thus we must ensure bytes not greater thanTPS6507X_MAX_REGISTER.
Thanks, patch applied to my for-next tree.
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/