All of lore.kernel.org
 help / color / mirror / Atom feed
From: gregkh@suse.de (Greg KH)
To: lm-sensors@vger.kernel.org
Subject: [lm-sensors] [PATCH] i2c: Several PEC-related fixes in software
Date: Sat, 29 Oct 2005 01:12:36 +0000	[thread overview]
Message-ID: <11305336582271@kroah.com> (raw)

[PATCH] i2c: Several PEC-related fixes in software SMBus emulation

Fix several errors in I2C SMBus emulation when PEC is used:
* Weird logic error in SMBus Write Word transactions.
* Wrong buffer size, affecting SMBus Block Write transactions.
* Potential buffer overrun in SMBus Block Write transactions.

From: Hideki Iwamoto <h-iwamoto@kit.hi-ho.ne.jp>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

 drivers/i2c/i2c-core.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

---
commit 5c50d1885981537ff3b8df6433951de6c9cb72cb
tree 1440c92b1716fb27a93c96fc9494aa7980421d95
parent 0f69a612f950f7508e556bf1b09390087d112115
author Hideki Iwamoto <h-iwamoto@kit.hi-ho.ne.jp> Sun, 25 Sep 2005 17:01:11 +0200
committer Greg Kroah-Hartman <gregkh@suse.de> Fri, 28 Oct 2005 14:02:07 -0700

 drivers/i2c/i2c-core.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index b55097d..9583a54 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -864,7 +864,7 @@ static int i2c_smbus_add_pec(u16 addr, u
 			break;
 		case I2C_SMBUS_BYTE_DATA:
 			buf[2] = data->byte;
-			data->word = buf[2] ||
+			data->word = buf[2] |
 			            (i2c_smbus_pec(3, buf, NULL) << 8);
 			size = I2C_SMBUS_WORD_DATA;
 			break;
@@ -1033,8 +1033,8 @@ static s32 i2c_smbus_xfer_emulated(struc
 	  need to use only one message; when reading, we need two. We initialize
 	  most things with sane defaults, to keep the code below somewhat
 	  simpler. */
-	unsigned char msgbuf0[34];
-	unsigned char msgbuf1[34];
+	unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3];
+	unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2];
 	int num = read_write = I2C_SMBUS_READ?2:1;
 	struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, 
 	                          { addr, flags | I2C_M_RD, 0, msgbuf1 }
@@ -1097,7 +1097,7 @@ static s32 i2c_smbus_xfer_emulated(struc
 			}
 			if(size = I2C_SMBUS_BLOCK_DATA_PEC)
 				(msg[0].len)++;
-			for (i = 1; i <= msg[0].len; i++)
+			for (i = 1; i < msg[0].len; i++)
 				msgbuf0[i] = data->block[i-1];
 		}
 		break;


                 reply	other threads:[~2005-10-29  1:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11305336582271@kroah.com \
    --to=gregkh@suse.de \
    --cc=lm-sensors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.