From: Mark Ware <mware@elphinstone.net>
To: linux-mtd@lists.infradead.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Subject: [RFC/PATCH] doc2000: Fix uninitialized variable in doc_ecc_decode()
Date: Thu, 27 May 2010 11:45:39 +1000 [thread overview]
Message-ID: <4BFDCEC3.7070601@elphinstone.net> (raw)
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 */
--
1.5.6.5
next reply other threads:[~2010-05-27 1:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-27 1:45 Mark Ware [this message]
2010-06-17 4:44 ` [RFC/PATCH] doc2000: Fix uninitialized variable in doc_ecc_decode() Mark Ware
2010-06-29 3:46 ` Artem Bityutskiy
2010-06-29 3:58 ` Artem Bityutskiy
2010-06-29 6:29 ` Artem Bityutskiy
2010-06-29 6:47 ` Mark Ware
2010-06-29 6:50 ` Artem Bityutskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BFDCEC3.7070601@elphinstone.net \
--to=mware@elphinstone.net \
--cc=linux-mtd@lists.infradead.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.