From mboxrd@z Thu Jan 1 00:00:00 1970 From: Laura Abbott Subject: Re: [PATCH 3/4] gpio: Remove VLA from xra1403 driver Date: Wed, 28 Mar 2018 10:27:09 -0700 Message-ID: <90ca44b5-52d0-be74-f36c-55d6f4a9bf25@redhat.com> References: <20180310001021.6437-1-labbott@redhat.com> <20180310001021.6437-4-labbott@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: Geert Uytterhoeven Cc: Linus Walleij , Kees Cook , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List , kernel-hardening@lists.openwall.com List-Id: linux-gpio@vger.kernel.org On 03/28/2018 12:27 AM, Geert Uytterhoeven wrote: > Hi Laura, > > On Sat, Mar 10, 2018 at 1:10 AM, Laura Abbott wrote: >> 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: Laura Abbott > > Thanks for your patch! > >> --- a/drivers/gpio/gpio-xra1403.c >> +++ b/drivers/gpio/gpio-xra1403.c >> @@ -126,11 +126,16 @@ static void xra1403_dbg_show(struct seq_file *s, struct gpio_chip *chip) >> { >> int reg; >> struct xra1403 *xra = gpiochip_get_data(chip); >> - int value[xra1403_regmap_cfg.max_register]; > > Apparently xra1403_regmap_cfg.max_register is always 0x15? > > What about adding > > #define XRA_LAST 15 > > at the top, and replacing both "XRA_IFR | 0x01" and > xra1403_regmap_cfg.max_register by XRA_LAST instead? > That would avoid doing yet another memory allocation over and over. > > Gr{oetje,eeting}s, > > Geert > I'm okay with making the change but I think Linus already picked up the patch into his gpio trees. Linus, do you want a patch on top of your -devel branch or should I just send a new patch? Thanks, Laura