Skip to contentSkip to conversation

Possible off-by-one error in fscpos

lm-sensors Jean Delvare 2 participants 2 messages Aug 25, 2005 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

Hi Stefan,

Coverity uncovered a possible off-by-one error in your Linux 2.6 fscpos driver, in function set_temp_reset. I believe it is correct, and the fix is probably as simple as:

 drivers/hwmon/fscpos.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/fscpos.c +1 -1
@@ -168,7 +168,7 @@
 				"experience to the module author.\n");
 
 	/* Supported value: 2 (clears the status) */
-	fscpos_write_value(client, FSCPOS_REG_TEMP_STATE[nr], 2);
+	fscpos_write_value(client, FSCPOS_REG_TEMP_STATE[nr - 1], 2);
 	return count;
 }
 

Can you please comment on this, confirm the problem and solution, and test the patch?

Thanks,

Signature · 1 line
Jean Delvare
#1 lore raw

Hi Jean

You're right, that should be nr-1. However, I can't test it because what it does is clear a temperature alert - I would have to remove/disable the CPU's heatsink in order to get such an alert in the first place. What I could test was which values are actually passed as nr and, as you noticed, those values are between 1 and 3, not between 0 and 2.

Regards
Stefan

Quoted 27 lines · Jean Delvare

Hi Stefan,

Coverity uncovered a possible off-by-one error in your Linux 2.6 fscpos driver, in function set_temp_reset. I believe it is correct, and the fix is probably as simple as:

 drivers/hwmon/fscpos.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/fscpos.c +1 -1
@@ -168,7 +168,7 @@
 				"experience to the module author.\n");
 
 	/* Supported value: 2 (clears the status) */
-	fscpos_write_value(client, FSCPOS_REG_TEMP_STATE[nr], 2);
+	fscpos_write_value(client, FSCPOS_REG_TEMP_STATE[nr - 1], 2);
 	return count;
 }
 

Can you please comment on this, confirm the problem and solution, and test the patch?

Thanks,

Signature · 1 line
Jean Delvare
Signature · 12 lines
Stefan Ott
http://www.desire.ch/

"Give a man a fire and he's warm for a day, but set fire to him and he's
warm for the rest of his life."  -- Terry Pratchett, Jingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20050825/22597e10/attachment.bin