diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2018-04-22 18:23:46 +0200 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2018-04-24 19:50:04 -0700 |
commit | 83a530e1610ab996e59c0941db6cc72f763dddbd (patch) | |
tree | c5abcba7d5b8213ec3ddc39cb7508d80aab08469 /include/linux/rslib.h | |
parent | 6d08b06e67cd117f6992c46611dfb4ce267cd71e (diff) | |
download | lwn-83a530e1610ab996e59c0941db6cc72f763dddbd.tar.gz lwn-83a530e1610ab996e59c0941db6cc72f763dddbd.zip |
rslib: Add GFP aware init function
The rslib usage in dm/verity_fec is broken because init_rs() can nest in
GFP_NOIO mempool allocations as init_rs() is invoked from the mempool alloc
callback.
Provide a variant which takes gfp_t flags as argument.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Alasdair Kergon <agk@redhat.com>
Cc: Neil Brown <neilb@suse.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'include/linux/rslib.h')
-rw-r--r-- | include/linux/rslib.h | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/include/linux/rslib.h b/include/linux/rslib.h index 746580c1939c..2aae7ef987eb 100644 --- a/include/linux/rslib.h +++ b/include/linux/rslib.h @@ -20,6 +20,8 @@ #define _RSLIB_H_ #include <linux/list.h> +#include <linux/types.h> /* for gfp_t */ +#include <linux/gfp.h> /* for GFP_KERNEL */ /** * struct rs_control - rs control structure @@ -77,10 +79,30 @@ int decode_rs16(struct rs_control *rs, uint16_t *data, uint16_t *par, int len, #endif /* Create or get a matching rs control structure */ -struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim, - int nroots); +struct rs_control *init_rs_gfp(int symsize, int gfpoly, int fcr, int prim, + int nroots, gfp_t gfp); + +/** + * init_rs - Create a RS control struct and initialize it + * @symsize: the symbol size (number of bits) + * @gfpoly: the extended Galois field generator polynomial coefficients, + * with the 0th coefficient in the low order bit. The polynomial + * must be primitive; + * @fcr: the first consecutive root of the rs code generator polynomial + * in index form + * @prim: primitive element to generate polynomial roots + * @nroots: RS code generator polynomial degree (number of roots) + * + * Allocations use GFP_KERNEL. + */ +static inline struct rs_control *init_rs(int symsize, int gfpoly, int fcr, + int prim, int nroots) +{ + return init_rs_gfp(symsize, gfpoly, fcr, prim, nroots, GFP_KERNEL); +} + struct rs_control *init_rs_non_canonical(int symsize, int (*func)(int), - int fcr, int prim, int nroots); + int fcr, int prim, int nroots); /* Release a rs control structure */ void free_rs(struct rs_control *rs); |