From patchwork Thu May 27 01:45:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Ware X-Patchwork-Id: 53677 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7D80DB7D12 for ; Thu, 27 May 2010 11:47:38 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1OHSAS-0000Ku-GC; Thu, 27 May 2010 01:45:52 +0000 Received: from ipmail04.adl6.internode.on.net ([150.101.137.141]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1OHSAO-0000Jc-VK for linux-mtd@lists.infradead.org; Thu, 27 May 2010 01:45:49 +0000 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvoBAOZo/Ut20Wus/2dsb2JhbAAHkhDAGY4bhRME Received: from ppp118-209-107-172.lns20.mel4.internode.on.net (HELO [192.168.1.8]) ([118.209.107.172]) by ipmail04.adl6.internode.on.net with ESMTP; 27 May 2010 11:15:41 +0930 Message-ID: <4BFDCEC3.7070601@elphinstone.net> Date: Thu, 27 May 2010 11:45:39 +1000 From: Mark Ware User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090707) MIME-Version: 1.0 To: linux-mtd@lists.infradead.org Subject: [RFC/PATCH] doc2000: Fix uninitialized variable in doc_ecc_decode() X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100526_214549_315204_34D513DF X-CRM114-Status: GOOD ( 12.71 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- Cc: Thomas Gleixner X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The variable 'syn' was being used uninitialized. Also fixed incorrect use of syn[] vs s[]. Tested on powerpc board with 64MB DOC2000. --- I am porting from a 2.4.18 kernel to 2.6.32, and I saw random media header mismatches causing a failure to detect the DOC device partitions. Tracing through, I saw this variable being used uninitialized and I suspect incorrectly also. I do not really understand how the ecc/syndrome code works, so I do not know if this patch is the correct solution, but it did make my problem go away... CC: Thomas Gleixner as I believe he may have written this function initially. drivers/mtd/nand/diskonchip.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c index a5bf9ff..7da2321 100644 --- a/drivers/mtd/nand/diskonchip.c +++ b/drivers/mtd/nand/diskonchip.c @@ -145,6 +145,7 @@ static int doc_ecc_decode(struct rs_control *rs, uint8_t *data, uint8_t *ecc) uint8_t parity; uint16_t ds[4], s[5], tmp, errval[8], syn[4]; + memset(syn, 0, sizeof(syn)); /* Convert the ecc bytes into words */ ds[0] = ((ecc[4] & 0xff) >> 0) | ((ecc[5] & 0x03) << 8); ds[1] = ((ecc[5] & 0xfc) >> 2) | ((ecc[2] & 0x0f) << 6); @@ -168,9 +169,9 @@ static int doc_ecc_decode(struct rs_control *rs, uint8_t *data, uint8_t *ecc) s[i] ^= rs->alpha_to[rs_modnn(rs, tmp + (FCR + i) * j)]; } - /* Calc s[i] = s[i] / alpha^(v + i) */ + /* Calc syn[i] = s[i] / alpha^(v + i) */ for (i = 0; i < NROOTS; i++) { - if (syn[i]) + if (s[i]) syn[i] = rs_modnn(rs, rs->index_of[s[i]] + (NN - FCR - i)); } /* Call the decoder library */