* I2C updates for 2.4.28
@ 2004-11-20 11:54 Jean Delvare
2004-11-20 12:07 ` [PATCH 2.4] I2C updates for 2.4.28 (1/5) Jean Delvare
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Jean Delvare @ 2004-11-20 11:54 UTC (permalink / raw)
To: Marcelo Tosatti, LKML
Hi Marcelo, hi all,
I have a number of I2C updates for 2.4.28 waiting. All of them are
rather small and independent, gathered during the 2.4.27 cycle as user
reported problems and we fixed them in i2c CVS.
Individual patches follow, please apply.
Thanks.
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2.4] I2C updates for 2.4.28 (1/5)
2004-11-20 11:54 I2C updates for 2.4.28 Jean Delvare
@ 2004-11-20 12:07 ` Jean Delvare
2004-11-20 12:16 ` [PATCH 2.4] I2C updates for 2.4.28 (2/5) Jean Delvare
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Jean Delvare @ 2004-11-20 12:07 UTC (permalink / raw)
To: Marcelo Tosatti, LKML
Original report and discussion:
http://archives.andrew.net.au/lm-sensors/msg18839.html
Bottom line:
i2c_register_entry shouldn't rely on the procname field to detect the
end of the control table, but on the ctl_name field. The latter is
guaranteed to be non-zero except for the table terminator, the former
can be null even in the middle of the table.
The bug wasn't caught so far because all users of this function
(basically the lm_sensors project's drivers) were exporting all entries
through /proc so procname was never null (except for the table
terminator, obviously).
Credits go to Louis-Martin Cote for discovering the bug and proposing a
fix.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
--- linux-2.4.28-pre3/drivers/i2c/i2c-proc.c.orig 2004-09-29 22:35:29.000000000 +0200
+++ linux-2.4.28-pre3/drivers/i2c/i2c-proc.c 2004-09-29 22:34:59.000000000 +0200
@@ -152,7 +152,7 @@
id += 256;
len = 0;
- while (ctl_template[len].procname)
+ while (ctl_template[len].ctl_name)
len++;
len += 7;
if (!(new_table = kmalloc(sizeof(ctl_table) * len, GFP_KERNEL))) {
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2.4] I2C updates for 2.4.28 (2/5)
2004-11-20 11:54 I2C updates for 2.4.28 Jean Delvare
2004-11-20 12:07 ` [PATCH 2.4] I2C updates for 2.4.28 (1/5) Jean Delvare
@ 2004-11-20 12:16 ` Jean Delvare
2004-11-20 12:26 ` [PATCH 2.4] I2C updates for 2.4.28 (3/5) Jean Delvare
2004-11-20 12:42 ` [PATCH 2.4] I2C updates for 2.4.28 (5/5) Jean Delvare
3 siblings, 0 replies; 5+ messages in thread
From: Jean Delvare @ 2004-11-20 12:16 UTC (permalink / raw)
To: Marcelo Tosatti, LKML
Original report and discussion:
http://archives.andrew.net.au/lm-sensors/msg28053.html
Bottom line:
The real parser in i2c-proc is partly broken, but in a way it will go
unnoticed in most cases (thus unspotted so far). Still worth fixing
IMHO.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
--- linux-2.4.28-pre4/drivers/i2c/i2c-proc.c.orig 2004-10-16 12:44:30.000000000 +0200
+++ linux-2.4.28-pre4/drivers/i2c/i2c-proc.c 2004-10-16 12:46:38.000000000 +0200
@@ -540,7 +540,7 @@
/* Skip everything until we hit whitespace */
while (bufsize &&
!((ret=get_user(nextchar, (char *) buffer))) &&
- isspace((int) nextchar)) {
+ !isspace((int) nextchar)) {
bufsize--;
((char *) buffer)++;
}
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2.4] I2C updates for 2.4.28 (3/5)
2004-11-20 11:54 I2C updates for 2.4.28 Jean Delvare
2004-11-20 12:07 ` [PATCH 2.4] I2C updates for 2.4.28 (1/5) Jean Delvare
2004-11-20 12:16 ` [PATCH 2.4] I2C updates for 2.4.28 (2/5) Jean Delvare
@ 2004-11-20 12:26 ` Jean Delvare
2004-11-20 12:42 ` [PATCH 2.4] I2C updates for 2.4.28 (5/5) Jean Delvare
3 siblings, 0 replies; 5+ messages in thread
From: Jean Delvare @ 2004-11-20 12:26 UTC (permalink / raw)
To: Marcelo Tosatti, LKML
Original report and discussion:
http://marc.theaimsgroup.com/?l=linux-arm-kernel&m=109816546827995&w=2
http://marc.theaimsgroup.com/?l=linux-arm-kernel&m=109926079025024&w=2
Bottom line:
Two hardcoded buffer sizes in i2c_smbus_xfer_emulated (i2c-core) should
depend on I2C_SMBUS_BLOCK_MAX. Else increasing I2C_SMBUS_BLOCK_MAX (in
include/linux/i2c.h) will result in buffer overflows.
Credits go to Tehn Yit Chin for noticing the suspicious hardcoded
values.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
--- linux-2.4.28-rc1/drivers/i2c/i2c-core.c.orig 2004-10-27 23:45:48.000000000 +0200
+++ linux-2.4.28-rc1/drivers/i2c/i2c-core.c 2004-10-29 19:18:09.000000000 +0200
@@ -1098,8 +1098,8 @@
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+2];
+ 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 }
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2.4] I2C updates for 2.4.28 (5/5)
2004-11-20 11:54 I2C updates for 2.4.28 Jean Delvare
` (2 preceding siblings ...)
2004-11-20 12:26 ` [PATCH 2.4] I2C updates for 2.4.28 (3/5) Jean Delvare
@ 2004-11-20 12:42 ` Jean Delvare
3 siblings, 0 replies; 5+ messages in thread
From: Jean Delvare @ 2004-11-20 12:42 UTC (permalink / raw)
To: Marcelo Tosatti, LKML
Original report and discussion:
http://archives.andrew.net.au/lm-sensors/msg28295.html
Bottom line:
Some debug messages in the i2c-core lack their trailing newline, which
breaks the logs.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
diff -ruN linux-2.4.28-rc2/drivers/i2c.orig/i2c-core.c linux-2.4.28-rc2/drivers/i2c/i2c-core.c
--- linux-2.4.28-rc2/drivers/i2c.orig/i2c-core.c 2004-11-09 22:02:16.000000000 +0100
+++ linux-2.4.28-rc2/drivers/i2c/i2c-core.c 2004-11-09 22:04:41.000000000 +0100
@@ -901,7 +901,7 @@
if (addr == address_data->normal_i2c[i]) {
found = 1;
DEB2(printk(KERN_DEBUG "i2c-core.o: found normal i2c entry for adapter %d, "
- "addr %02x", adap_id,addr));
+ "addr %02x\n", adap_id, addr));
}
}
diff -ruN linux-2.4.28-rc2/drivers/i2c.orig/i2c-proc.c linux-2.4.28-rc2/drivers/i2c/i2c-proc.c
--- linux-2.4.28-rc2/drivers/i2c.orig/i2c-proc.c 2004-11-09 22:02:09.000000000 +0100
+++ linux-2.4.28-rc2/drivers/i2c/i2c-proc.c 2004-11-09 22:03:59.000000000 +0100
@@ -762,7 +762,7 @@
#ifdef DEBUG
printk
(KERN_DEBUG "i2c-proc.o: found normal isa_range entry for adapter %d, "
- "addr %04x", adapter_id, addr);
+ "addr %04x\n", adapter_id, addr);
#endif
found = 1;
}
@@ -776,7 +776,7 @@
#ifdef DEBUG
printk
(KERN_DEBUG "i2c-proc.o: found normal i2c entry for adapter %d, "
- "addr %02x", adapter_id, addr);
+ "addr %02x\n", adapter_id, addr);
#endif
}
}
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-11-20 12:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-20 11:54 I2C updates for 2.4.28 Jean Delvare
2004-11-20 12:07 ` [PATCH 2.4] I2C updates for 2.4.28 (1/5) Jean Delvare
2004-11-20 12:16 ` [PATCH 2.4] I2C updates for 2.4.28 (2/5) Jean Delvare
2004-11-20 12:26 ` [PATCH 2.4] I2C updates for 2.4.28 (3/5) Jean Delvare
2004-11-20 12:42 ` [PATCH 2.4] I2C updates for 2.4.28 (5/5) Jean Delvare
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox