diff options
author | Kees Cook <keescook@chromium.org> | 2018-06-28 20:04:21 -0400 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2018-08-13 16:40:52 -0400 |
commit | d8dfa59f5a512a536b80a4a8f12fa993683f48df (patch) | |
tree | 7060f000c65ca25700fa42da810a5875f7f9a710 | |
parent | 699112f5e831c088ff6aeea594d23ebecf6bd806 (diff) |
bus: imx-weim: Remove VLA usage
In the quest to remove all stack VLA usage from the kernel[1], this
switches to using a maximum size and adds a sanity check.
[1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Shawn Guo <shawnguo@kernel.org>
-rw-r--r-- | drivers/bus/imx-weim.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c index 3d56ebcda720..6a94aa6a22c2 100644 --- a/drivers/bus/imx-weim.c +++ b/drivers/bus/imx-weim.c | |||
@@ -45,6 +45,8 @@ static const struct imx_weim_devtype imx51_weim_devtype = { | |||
45 | .cs_stride = 0x18, | 45 | .cs_stride = 0x18, |
46 | }; | 46 | }; |
47 | 47 | ||
48 | #define MAX_CS_REGS_COUNT 6 | ||
49 | |||
48 | static const struct of_device_id weim_id_table[] = { | 50 | static const struct of_device_id weim_id_table[] = { |
49 | /* i.MX1/21 */ | 51 | /* i.MX1/21 */ |
50 | { .compatible = "fsl,imx1-weim", .data = &imx1_weim_devtype, }, | 52 | { .compatible = "fsl,imx1-weim", .data = &imx1_weim_devtype, }, |
@@ -112,9 +114,12 @@ err: | |||
112 | static int __init weim_timing_setup(struct device_node *np, void __iomem *base, | 114 | static int __init weim_timing_setup(struct device_node *np, void __iomem *base, |
113 | const struct imx_weim_devtype *devtype) | 115 | const struct imx_weim_devtype *devtype) |
114 | { | 116 | { |
115 | u32 cs_idx, value[devtype->cs_regs_count]; | 117 | u32 cs_idx, value[MAX_CS_REGS_COUNT]; |
116 | int i, ret; | 118 | int i, ret; |
117 | 119 | ||
120 | if (WARN_ON(devtype->cs_regs_count > MAX_CS_REGS_COUNT)) | ||
121 | return -EINVAL; | ||
122 | |||
118 | /* get the CS index from this child node's "reg" property. */ | 123 | /* get the CS index from this child node's "reg" property. */ |
119 | ret = of_property_read_u32(np, "reg", &cs_idx); | 124 | ret = of_property_read_u32(np, "reg", &cs_idx); |
120 | if (ret) | 125 | if (ret) |