diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-05 10:48:05 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-05 10:48:05 -0700 |
commit | 25d80be86c5d7f53df41ec5ce96f6c6543cac245 (patch) | |
tree | a18fe8d5281d0ed44c049d5a59da499278bb6e3e /lib/reed_solomon/decode_rs.c | |
parent | a74e0c4c9cb02d44bc5ec1a70a6ba599366fb130 (diff) | |
parent | 45888b40d2a6221d46bb69959e2600ddba71cc1f (diff) | |
download | linux-25d80be86c5d7f53df41ec5ce96f6c6543cac245.tar.bz2 |
Merge tag 'rslib-v4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull reed-salomon library updates from Kees Cook:
"Refactors rslib and callers to provide a per-instance allocation area
instead of performing VLAs on the stack"
* tag 'rslib-v4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
rslib: Allocate decoder buffers to avoid VLAs
mtd: rawnand: diskonchip: Allocate rs control per instance
rslib: Split rs control struct
rslib: Simplify error path
rslib: Remove GPL boilerplate
rslib: Add SPDX identifiers
rslib: Cleanup top level comments
rslib: Cleanup whitespace damage
dm/verity_fec: Use GFP aware reed solomon init
rslib: Add GFP aware init function
Diffstat (limited to 'lib/reed_solomon/decode_rs.c')
-rw-r--r-- | lib/reed_solomon/decode_rs.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/lib/reed_solomon/decode_rs.c b/lib/reed_solomon/decode_rs.c index 0ec3f257ffdf..1db74eb098d0 100644 --- a/lib/reed_solomon/decode_rs.c +++ b/lib/reed_solomon/decode_rs.c @@ -1,22 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0 /* - * lib/reed_solomon/decode_rs.c - * - * Overview: - * Generic Reed Solomon encoder / decoder library + * Generic Reed Solomon encoder / decoder library * * Copyright 2002, Phil Karn, KA9Q * May be used under the terms of the GNU General Public License (GPL) * * Adaption to the kernel by Thomas Gleixner (tglx@linutronix.de) * - * $Id: decode_rs.c,v 1.7 2005/11/07 11:14:59 gleixner Exp $ - * - */ - -/* Generic data width independent code which is included by the - * wrappers. + * Generic data width independent code which is included by the wrappers. */ { + struct rs_codec *rs = rsc->codec; int deg_lambda, el, deg_omega; int i, j, r, k, pad; int nn = rs->nn; @@ -27,16 +21,22 @@ uint16_t *alpha_to = rs->alpha_to; uint16_t *index_of = rs->index_of; uint16_t u, q, tmp, num1, num2, den, discr_r, syn_error; - /* Err+Eras Locator poly and syndrome poly The maximum value - * of nroots is 8. So the necessary stack size will be about - * 220 bytes max. - */ - uint16_t lambda[nroots + 1], syn[nroots]; - uint16_t b[nroots + 1], t[nroots + 1], omega[nroots + 1]; - uint16_t root[nroots], reg[nroots + 1], loc[nroots]; int count = 0; uint16_t msk = (uint16_t) rs->nn; + /* + * The decoder buffers are in the rs control struct. They are + * arrays sized [nroots + 1] + */ + uint16_t *lambda = rsc->buffers + RS_DECODE_LAMBDA * (nroots + 1); + uint16_t *syn = rsc->buffers + RS_DECODE_SYN * (nroots + 1); + uint16_t *b = rsc->buffers + RS_DECODE_B * (nroots + 1); + uint16_t *t = rsc->buffers + RS_DECODE_T * (nroots + 1); + uint16_t *omega = rsc->buffers + RS_DECODE_OMEGA * (nroots + 1); + uint16_t *root = rsc->buffers + RS_DECODE_ROOT * (nroots + 1); + uint16_t *reg = rsc->buffers + RS_DECODE_REG * (nroots + 1); + uint16_t *loc = rsc->buffers + RS_DECODE_LOC * (nroots + 1); + /* Check length parameter for validity */ pad = nn - nroots - len; BUG_ON(pad < 0 || pad >= nn); |