Commit 13b5319e authored by Laura Abbott's avatar Laura Abbott Committed by Linus Walleij

gpio: Remove VLA from xra1403 driver

The new challenge is to remove VLAs from the kernel
(see https://lkml.org/lkml/2018/3/7/621)

This patch replaces a VLA with an appropriate call to kmalloc_array.
Signed-off-by: default avatarLaura Abbott <labbott@redhat.com>
Reviewed-by: default avatarNandor Han <nandor.han@ge.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 48da181d
...@@ -126,11 +126,16 @@ static void xra1403_dbg_show(struct seq_file *s, struct gpio_chip *chip) ...@@ -126,11 +126,16 @@ static void xra1403_dbg_show(struct seq_file *s, struct gpio_chip *chip)
{ {
int reg; int reg;
struct xra1403 *xra = gpiochip_get_data(chip); struct xra1403 *xra = gpiochip_get_data(chip);
int value[xra1403_regmap_cfg.max_register]; int *value;
int i; int i;
unsigned int gcr; unsigned int gcr;
unsigned int gsr; unsigned int gsr;
value = kmalloc_array(xra1403_regmap_cfg.max_register, sizeof(*value),
GFP_KERNEL);
if (!value)
return;
seq_puts(s, "xra reg:"); seq_puts(s, "xra reg:");
for (reg = 0; reg <= xra1403_regmap_cfg.max_register; reg++) for (reg = 0; reg <= xra1403_regmap_cfg.max_register; reg++)
seq_printf(s, " %2.2x", reg); seq_printf(s, " %2.2x", reg);
...@@ -154,6 +159,7 @@ static void xra1403_dbg_show(struct seq_file *s, struct gpio_chip *chip) ...@@ -154,6 +159,7 @@ static void xra1403_dbg_show(struct seq_file *s, struct gpio_chip *chip)
(gcr & BIT(i)) ? "in" : "out", (gcr & BIT(i)) ? "in" : "out",
(gsr & BIT(i)) ? "hi" : "lo"); (gsr & BIT(i)) ? "hi" : "lo");
} }
kfree(value);
} }
#else #else
#define xra1403_dbg_show NULL #define xra1403_dbg_show NULL
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment