diff mbox

[v2,1/2,i2c-tools] decode-dimms: Complete check for out-of-bounds vendor ID

Message ID 20150601092614.539ebc75@endymion.delvare
State Awaiting Upstream
Headers show

Commit Message

Jean Delvare June 1, 2015, 7:26 a.m. UTC
We also need to discard vendor ID 0 and to report "Unknown" if the
vendor is in a page we don't support yet.

Additionally, check that data is present at all for DDR3 modules as we
already do for pre-DDR3 modules.
---
Changes since v1:
 * Added check for data presence.

 eeprom/decode-dimms |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox

Patch

--- i2c-tools.orig/eeprom/decode-dimms	2015-06-01 08:19:59.292190666 +0200
+++ i2c-tools/eeprom/decode-dimms	2015-06-01 09:14:30.899898763 +0200
@@ -344,8 +344,12 @@  sub manufacturer_ddr3($$)
 	my ($count, $code) = @_;
 	my $manufacturer;
 
-	return "Invalid" if parity($code) != 1;
-	return "Unknown" if ($code & 0x7F) - 1 >= @{$vendors[$count & 0x7F]};
+	return "Undefined" unless spd_written($count, $code);
+
+	return "Invalid" if parity($code) != 1
+			 or ($code & 0x7F) == 0;
+	return "Unknown" if ($count & 0x7F) >= @vendors
+			 or ($code & 0x7F) - 1 >= @{$vendors[$count & 0x7F]};
 	$manufacturer = $vendors[$count & 0x7F][($code & 0x7F) - 1];
 	$manufacturer =~ s/ \(former .*\)$// if $opt_side_by_side;
 	$manufacturer .= "? (Invalid parity)" if parity($count) != 1;