mtd: doc2000: fix uninitialized variable in doc_ecc_decode()

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Wed Aug 4 06:59:07 EDT 2010


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=c9fb67735b307a3cdf57e568b6c50c860248d1d3
Commit:     c9fb67735b307a3cdf57e568b6c50c860248d1d3
Parent:     7b0507eb697ea157533b9a7e0a955f64a00b1b1d
Author:     Mark Ware <mware at elphinstone.net>
AuthorDate: Thu May 27 11:45:39 2010 +1000
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Wed Aug 4 10:56:06 2010 +0100

    mtd: doc2000: fix uninitialized variable in doc_ecc_decode()
    
    The variable 'syn' was being used uninitialized.  Also
    fixed incorrect use of syn[] vs s[].
    
    Tested on powerpc board with 64MiB DOC2000.
    
    Signed-off-by: Mark Ware <mware at elphinstone.net>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 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 47067bc..51315f5 100644
--- a/drivers/mtd/nand/diskonchip.c
+++ b/drivers/mtd/nand/diskonchip.c
@@ -146,6 +146,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);
@@ -169,9 +170,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 */



More information about the linux-mtd-cvs mailing list