From patchwork Mon Jun 1 07:26:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Delvare X-Patchwork-Id: 478785 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 0D444140E5E for ; Mon, 1 Jun 2015 17:26:20 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750974AbbFAH0T (ORCPT ); Mon, 1 Jun 2015 03:26:19 -0400 Received: from cantor2.suse.de ([195.135.220.15]:49752 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750936AbbFAH0S (ORCPT ); Mon, 1 Jun 2015 03:26:18 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 5D565AD8C; Mon, 1 Jun 2015 07:26:16 +0000 (UTC) Date: Mon, 1 Jun 2015 09:26:14 +0200 From: Jean Delvare To: Linux I2C Cc: Lubomir Rintel Subject: [PATCH v2 1/2 i2c-tools] decode-dimms: Complete check for out-of-bounds vendor ID Message-ID: <20150601092614.539ebc75@endymion.delvare> Organization: SUSE Linux X-Mailer: Claws Mail 3.10.1 (GTK+ 2.24.23; x86_64-suse-linux-gnu) MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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(-) --- 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;