Skip to contentSkip to conversation

i2c: fix scx200_acb block transactions

PATCH New Jean Delvare 1 participant 2 messages Jun 8, 2006 – Jun 11, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: fix scx200_acb block transactions

Greg,

This would be a better fix. I would much appreciate if someone with an scx200_acb bus could give it some testing, just in case. In particular testing the various modes of i2cdump on an EEPROM would be useful.

The scx200_acb i2c bus driver pretends to support SMBus block transactions, but in fact it implements the more simple I2C block transactions. Additionally, it lacks sanity checks on the length of the block transactions, which could lead to a buffer overrun.

This fixes an oops reported by Alexander Atanasov:
http://marc.theaimsgroup.com/?l=linux-kernel&m4970382125094

Signed-off-by Jean Delvare <khali at linux-fr.org>
---
 drivers/i2c/busses/scx200_acb.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/i2c/busses/scx200_acb.c +9 -3
@@ -304,8 +304,14 @@
 		buffer = (u8 *)&cur_word;
 		break;
 
-	case I2C_SMBUS_BLOCK_DATA:
-		len = data->block[0];
+	case I2C_SMBUS_I2C_BLOCK_DATA:
+		if (rw = I2C_SMBUS_READ) {
+			len = I2C_SMBUS_BLOCK_MAX;
+		} else {
+			len = data->block[0];
+			if (len = 0 || len > I2C_SMBUS_BLOCK_MAX)
+				return -EINVAL;
+		}
 		buffer = &data->block[1];
 		break;
 
@@ -369,7 +375,7 @@
 {
 	return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
 	       I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
-	       I2C_FUNC_SMBUS_BLOCK_DATA;
+	       I2C_FUNC_SMBUS_I2C_BLOCK;
 }
 
 /* For now, we only handle combined mode (smbus) */
Signature · 1 line
Jean Delvare
#1 lore raw

PATCH 1/1 i2c: fix scx200_acb block transactions

Greg,

Quoting myself:

Quoted 9 lines

This would be a better fix. I would much appreciate if someone with an scx200_acb bus could give it some testing, just in case. In particular testing the various modes of i2cdump on an EEPROM would be useful.

The scx200_acb i2c bus driver pretends to support SMBus block transactions, but in fact it implements the more simple I2C block transactions. Additionally, it lacks sanity checks on the length of the block transactions, which could lead to a buffer overrun.

As discussed earlier on IRC, please hold on with this patch as well. It is correct but uncovers older bugs in the scx200_acb driver state machine. We need to fix them before the functionality change itself is safe.

No big deal if it doesn't make it in 2.6.17, after all the bugs have been there for a very long time now and they are just being discovered and reported now so better wait a few more months and make sure we come up with a complete fix. After all, that's exactly what -stable was made for.

Thanks,

Signature · 1 line
Jean Delvare