Received: by 10.213.65.68 with SMTP id h4csp970757imn; Wed, 28 Mar 2018 17:08:37 -0700 (PDT) X-Google-Smtp-Source: AIpwx48f6a6voKlB6LeHIsPk8fV7O0FBgDiQZirfGqkGCCHR1nzadBbl97aVNJXk3mSbGdlSfl9k X-Received: by 2002:a17:902:85:: with SMTP id a5-v6mr5725872pla.99.1522282117787; Wed, 28 Mar 2018 17:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522282117; cv=none; d=google.com; s=arc-20160816; b=mYvzNmBXt9cp2gGBlHHKFe5h0+3L1cIUZ2yCILleoqn++BaHv/3XEMG/3hI5EMAryG E1HJ7/0JmCVnCJYFifybYEaW2JtNE5jjDP16MWR2fKkvVCNYgcAfDZq2cdI4wiRc7fBV u5bsfk6IbCivwkpzjCF/60RX13ZMwbSAWIHnDT3LWZawwpwd1HRO3HvNfkbtOl/Ld0rh 2MxWY8i8ielNdXxximECUMh7mC3QQY1+oZl72ZSrI5pkB9qst9m1x/ylJfhMTLxvcdRi nTwljuSjTgVs9C7fjJjDdOd4jeH4hScnHB5QXVP6uDD9l/6hnkZ7bxjGzkALlvpJb0kg 4xig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=GHxiHEQsZ+9v2gAnNlal3WXQSYme8NjFVACJvrpa9Vc=; b=Oi6yWTOXmsOwUQW9fd62ms/bHmp7vgubls1lKlAthF+3tdKPt/ODMkZfkMrjfDjddV ZHqbdgKBJU4hdL9YgdWJBWJTuImSprjb3e4qAW68abEYQkqiu5XoiUvgprUvpoJ52ae+ 8N7jwP9ltBaBsWDzCzBo9lFteGkLBHAIXhe1LCtjPd7Co7jPMK59uz9HbbOwlP/0uzBD 4U6Ycy1P5bXDfAJdeDzT/RDoP+mbO5bfHazX6ch57IDxy39Tzux4EA5nLoDE4Wf87/IC 57K8jwkmeblWf+DGDpcFFI2UIEImz31YxD7fhmnOefJemDW9CEdNImgGPoCsFR6OjgrZ ErsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n5si3599452pfi.360.2018.03.28.17.08.22; Wed, 28 Mar 2018 17:08:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751008AbeC2AHY (ORCPT + 99 others); Wed, 28 Mar 2018 20:07:24 -0400 Received: from anchovy1.45ru.net.au ([203.30.46.145]:53891 "EHLO anchovy1.45ru.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750732AbeC2AHW (ORCPT ); Wed, 28 Mar 2018 20:07:22 -0400 Received: (qmail 17882 invoked by uid 5089); 29 Mar 2018 00:07:19 -0000 Received: by simscan 1.2.0 ppid: 17794, pid: 17795, t: 0.0408s scanners: regex: 1.2.0 attach: 1.2.0 clamav: 0.88.3/m:40/d:1950 Received: from unknown (HELO ?192.168.0.122?) (preid@electromag.com.au@203.59.235.95) by anchovy1.45ru.net.au with ESMTPA; 29 Mar 2018 00:07:19 -0000 Subject: Re: [PATCH v3] gpio: Remove VLA from stmpe driver To: Laura Abbott , Linus Walleij , Kees Cook , Patrice Chotard Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com References: <20180328175957.23904-1-labbott@redhat.com> From: Phil Reid Message-ID: Date: Thu, 29 Mar 2018 08:07:05 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180328175957.23904-1-labbott@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-AU Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/03/2018 01:59, Laura Abbott wrote: > The new challenge is to remove VLAs from the kernel > (see https://lkml.org/lkml/2018/3/7/621) > > The number of GPIOs on the supported chips is fairly small > so stack allocate to a known upper bound and spit out a warning > if any new chips have more gpios. > > Signed-off-by: Laura Abbott > --- > v3: Split this off from the rest of the series since some of the > patches had been picked up. Switched to just hardcoding an upper > bound for the stack array since it's only a few extra bytes > of stack space. > --- > drivers/gpio/gpio-stmpe.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c > index f8d7d1cd8488..8d6a5a7e612d 100644 > --- a/drivers/gpio/gpio-stmpe.c > +++ b/drivers/gpio/gpio-stmpe.c > @@ -363,13 +363,15 @@ static struct irq_chip stmpe_gpio_irq_chip = { > .irq_set_type = stmpe_gpio_irq_set_type, > }; > > +#define MAX_GPIOS 24 > + > static irqreturn_t stmpe_gpio_irq(int irq, void *dev) > { > struct stmpe_gpio *stmpe_gpio = dev; > struct stmpe *stmpe = stmpe_gpio->stmpe; > u8 statmsbreg; > int num_banks = DIV_ROUND_UP(stmpe->num_gpios, 8); > - u8 status[num_banks]; > + u8 status[DIV_ROUND_UP(MAX_GPIOS, 8)]; > int ret; > int i; > > @@ -434,6 +436,11 @@ static int stmpe_gpio_probe(struct platform_device *pdev) > struct stmpe_gpio *stmpe_gpio; > int ret, irq; > > + if (stmpe->num_gpios > MAX_GPIOS) { > + dev_err(&pdev->dev, "Need to increase maximum GPIO number\n"); > + return -EINVAL; > + } > + > stmpe_gpio = kzalloc(sizeof(*stmpe_gpio), GFP_KERNEL); > if (!stmpe_gpio) > return -ENOMEM; > FWIW Reviewed-by: Phil Reid -- Regards Phil Reid