public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mfd: tps6507x - fix off-by-one value range checking
@ 2010-10-13  2:44 Axel Lin
  2010-10-19 10:19 ` Samuel Ortiz
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2010-10-13  2:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Samuel Ortiz, Todd Fischer

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 <axel.lin@gmail.com>
---
 drivers/mfd/tps6507x.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/tps6507x.c b/drivers/mfd/tps6507x.c
index fc01976..33ba772 100644
--- a/drivers/mfd/tps6507x.c
+++ b/drivers/mfd/tps6507x.c
@@ -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;
-- 
1.7.2




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mfd: tps6507x - fix off-by-one value range checking
  2010-10-13  2:44 [PATCH] mfd: tps6507x - fix off-by-one value range checking Axel Lin
@ 2010-10-19 10:19 ` Samuel Ortiz
  0 siblings, 0 replies; 2+ messages in thread
From: Samuel Ortiz @ 2010-10-19 10:19 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Todd Fischer

Hi Axel,

On Wed, Oct 13, 2010 at 10:44:39AM +0800, Axel Lin wrote:
> 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.
Thanks, patch applied to my for-next tree.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-10-19 10:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-13  2:44 [PATCH] mfd: tps6507x - fix off-by-one value range checking Axel Lin
2010-10-19 10:19 ` Samuel Ortiz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox