public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mfd: Fix off-by-one value range checking for tps65912_i2c_write
@ 2011-06-24 14:37 Axel Lin
  2011-07-04 15:23 ` Samuel Ortiz
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2011-06-24 14:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Margarita Olaya Cabrera, Liam Girdwood, Samuel Ortiz

>From c5124060f13296bfc8cbbbb8298cf4b9b1faa1e9 Mon Sep 17 00:00:00 2001
From: Axel Lin <axel.lin@gmail.com>
Date: Fri, 24 Jun 2011 15:34:16 +0800
Subject: [PATCH] mfd: Fix off-by-one value range checking for tps65912_i2c_write

If bytes == (TPS6591X_MAX_REGISTER + 1), we have a buffer overflow when
doing memcpy(&msg[1], src, bytes).

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/mfd/tps65912-i2c.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/tps65912-i2c.c b/drivers/mfd/tps65912-i2c.c
index 9ed123a..c041f2c 100644
--- a/drivers/mfd/tps65912-i2c.c
+++ b/drivers/mfd/tps65912-i2c.c
@@ -57,7 +57,7 @@ static int tps65912_i2c_write(struct tps65912 *tps65912, u8 reg,
 	u8 msg[TPS6591X_MAX_REGISTER + 1];
 	int ret;
 
-	if (bytes > (TPS6591X_MAX_REGISTER + 1))
+	if (bytes > TPS6591X_MAX_REGISTER)
 		return -EINVAL;
 
 	msg[0] = reg;
-- 
1.7.4.1




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

end of thread, other threads:[~2011-07-04 15:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-24 14:37 [PATCH] mfd: Fix off-by-one value range checking for tps65912_i2c_write Axel Lin
2011-07-04 15:23 ` Samuel Ortiz

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