drivers/hwmon/lm93.c: array overruns
The Coverity checker spotted the following array overruns in drivers/hwmon/lm93.c:
<-- snip -->
...
struct lm93_data {
...
struct {
u8 min;
u8 max;
} temp_lim[3];...
};
...
static void lm93_update_client_common(struct lm93_data *data,
struct i2c_client *client)
{
...
for (i = 0; i < 4; i++) {
data->temp_lim[i].min lm93_read_byte(client, LM93_REG_TEMP_MIN(i));
data->temp_lim[i].max lm93_read_byte(client, LM93_REG_TEMP_MAX(i));
}...
<-- snip -->
cu
Adrian
Signature · 10 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensorsAm Montag 23 Juli 2007 02:54 schrieb Adrian Bunk:
Quoted 19 lines
The Coverity checker spotted the following array overruns in
drivers/hwmon/lm93.c:<-- snip -->
...
structlm93_data{
...struct { u8 min; u8 max; } temp_lim[3];...
};
...
static void lm93_update_client_common(structlm93_data*data,
structi2c_client*client)
{
...
Quoted 7 lines
for (i = 0; i < 4; i++) { data->temp_lim[i].min > lm93_read_byte(client, LM93_REG_TEMP_MIN(i)); data->temp_lim[i].max > lm93_read_byte(client, LM93_REG_TEMP_MAX(i)); }...
<-- snip -->
This patch should fix it. Thanks a lot, Adrian!
----
This fixes an array overflow bug. We have 4 pairs of min/max temperature limits, not 3.
--
Index: linux-2.6.23-rc/drivers/hwmon/lm93.c
=================================--- linux-2.6.23-rc.orig/drivers/hwmon/lm93.c 2007-07-23 09:22:56.000000000 +0200
+++ linux-2.6.23-rc/drivers/hwmon/lm93.c 2007-07-23 09:29:37.000000000 +0200
@@ -234,7 +234,7 @@
struct {
u8 min;
u8 max;
- } temp_lim[3];
+ } temp_lim[4];
/* vin1 - vin16: low and high limits */
struct {
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Jean Delvare
Acked-byHi Hans,
Quoted 41 lines · Hans-Jürgen Koch
Am Montag 23 Juli 2007 02:54 schrieb Adrian Bunk:
Quoted 19 lines
The Coverity checker spotted the following array overruns in
drivers/hwmon/lm93.c:<-- snip -->
...
structlm93_data{
...struct { u8 min; u8 max; } temp_lim[3];...
};
...
static void lm93_update_client_common(structlm93_data*data,
structi2c_client*client)
{
...Quoted 7 lines
for (i = 0; i < 4; i++) { data->temp_lim[i].min > > lm93_read_byte(client, LM93_REG_TEMP_MIN(i)); data->temp_lim[i].max > > lm93_read_byte(client, LM93_REG_TEMP_MAX(i)); }...
<-- snip -->
This patch should fix it. Thanks a lot, Adrian!
----
This fixes an array overflow bug. We have 4 pairs of min/max temperature limits, not 3.Signed-off-by Hans J. Koch <[email protected]>--
Index:linux-2.6.23-rc/drivers/hwmon/lm93.c
=================================> ---linux-2.6.23-rc.orig/drivers/hwmon/lm93.c2007-07-23 09:22:56.000000000 +0200
+++linux-2.6.23-rc/drivers/hwmon/lm93.c2007-07-23 09:29:37.000000000 +0200
Review line 240
Quoted 8 lines
(quoted diff) +1
-1@@ -234,7 +234,7 @@ struct { u8 min; u8 max; - } temp_lim[3]; + } temp_lim[4]; /* vin1 - vin16: low and high limits */ struct {
This will do as a quick fix, so:
However, I see that temp4 (which isn't a real temperature channel) is not exposed in sysfs. Reading and storing register values you never use doesn't seem particularly interesting, so something needs to be done
here: either drop support for temp4 entirely, or expose the temp4 values in sysfs.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Am Dienstag 24 Juli 2007 10:10 schrieb Jean Delvare:
Quoted 55 lines
Hi Hans,
Quoted 41 lines · Hans-Jürgen Koch
Am Montag 23 Juli 2007 02:54 schrieb Adrian Bunk:
Quoted 19 lines
The Coverity checker spotted the following array overruns in
drivers/hwmon/lm93.c:<-- snip -->
...
structlm93_data{
...struct { u8 min; u8 max; } temp_lim[3];...
};
...
static void lm93_update_client_common(structlm93_data*data,
structi2c_client*client)
{
...Quoted 7 lines
for (i = 0; i < 4; i++) { data->temp_lim[i].min > > > lm93_read_byte(client, LM93_REG_TEMP_MIN(i)); data->temp_lim[i].max > > > lm93_read_byte(client, LM93_REG_TEMP_MAX(i)); }...
<-- snip -->
This patch should fix it. Thanks a lot, Adrian!
----
This fixes an array overflow bug. We have 4 pairs of min/max temperature limits, not 3.Signed-off-by Hans J. Koch <[email protected]>--
Index:linux-2.6.23-rc/drivers/hwmon/lm93.c
=================================> > ---linux-2.6.23-rc.orig/drivers/hwmon/lm93.c2007-07-23 09:22:56.000000000 +0200
+++linux-2.6.23-rc/drivers/hwmon/lm93.c2007-07-23 09:29:37.000000000 +0200Review line 240
Quoted 8 lines
(quoted diff) +1
-1@@ -234,7 +234,7 @@ struct { u8 min; u8 max; - } temp_lim[3]; + } temp_lim[4]; /* vin1 - vin16: low and high limits */ struct {This will do as a quick fix, so:
Quoted 7 lines
Acked-by Jean Delvare <[email protected]>However, I see that temp4 (which isn't a real temperature channel) is not exposed in sysfs. Reading and storing register values you never use doesn't seem particularly interesting, so something needs to be done
here: either drop support for temp4 entirely, or expose the temp4 values in sysfs.
I've got that on my TODO list. I'll soon work on that driver again. I'm still waiting for that #§$?& NDA-covered datasheet of the LM94. As soon as I've got that, I need to review all these values anyway because there might be subtle differences between LM93 and LM94.
For the moment, I'd like to postpone the decision about what to do with temp4.
Thanks anyway for pointing this out.
Hans
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Hans,
Quoted 7 lines · Hans-Jürgen Koch
Am Dienstag 24 Juli 2007 10:10 schrieb Jean Delvare:
Quoted 5 lines
However, I see that temp4 (which isn't a real temperature channel) is not exposed in sysfs. Reading and storing register values you never use doesn't seem particularly interesting, so something needs to be done
here: either drop support for temp4 entirely, or expose the temp4 values in sysfs.
Quoted 5 lines
I've got that on my TODO list. I'll soon work on that driver again. I'm still waiting for that #§$?& NDA-covered datasheet of the LM94. As soon as I've got that, I need to review all these values anyway because there might be subtle differences between LM93 and LM94.
For the moment, I'd like to postpone the decision about what to do with temp4.
Sure, no problem.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 43 lines · Hans-Jürgen Koch
Am Montag 23 Juli 2007 02:54 schrieb Adrian Bunk:
Quoted 19 lines
The Coverity checker spotted the following array overruns in
drivers/hwmon/lm93.c:<-- snip -->
...
structlm93_data{
...struct { u8 min; u8 max; } temp_lim[3];...
};
...
static void lm93_update_client_common(structlm93_data*data,
structi2c_client*client)
{
...Quoted 7 lines
for (i = 0; i < 4; i++) { data->temp_lim[i].min > > lm93_read_byte(client, LM93_REG_TEMP_MIN(i)); data->temp_lim[i].max > > lm93_read_byte(client, LM93_REG_TEMP_MAX(i)); }...
<-- snip -->
This patch should fix it. Thanks a lot, Adrian!
----
This fixes an array overflow bug. We have 4 pairs of min/max temperature limits, not 3.Signed-off-by Hans J. Koch <[email protected]>--
Index:linux-2.6.23-rc/drivers/hwmon/lm93.c
=================================> ---linux-2.6.23-rc.orig/drivers/hwmon/lm93.c2007-07-23 09:22:56.000000000 +0200
+++linux-2.6.23-rc/drivers/hwmon/lm93.c2007-07-23 09:29:37.000000000 +0200
Review line 240
Quoted 8 lines
(quoted diff) +1
-1@@ -234,7 +234,7 @@ struct { u8 min; u8 max; - } temp_lim[3]; + } temp_lim[4]; /* vin1 - vin16: low and high limits */ struct {
Applied to testing, thanks.
Signature · 8 lines
Mark M. Hoffman [email protected] _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors