Received: by 10.213.65.68 with SMTP id h4csp1568452imn; Mon, 19 Mar 2018 07:40:08 -0700 (PDT) X-Google-Smtp-Source: AG47ELtyzcjHsjPRbVrs377FzWLKxw3V7WTuPRLPtJ5niyue9V1ezzhxP9ldN416sQZuNchU9ykL X-Received: by 2002:a17:902:8212:: with SMTP id x18-v6mr2810499pln.372.1521470408225; Mon, 19 Mar 2018 07:40:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521470408; cv=none; d=google.com; s=arc-20160816; b=g7wlgCC/rWIZ7dvQAR8x9h44br/r2vKGsju0izpVNWlIJAmwN4+jwmFCg94RmrWReF 5TM5Gw+xAnZIsXpZMQr1xeQ8CgPZaluNRXeqEZ5X5WoTnNe96sOZItchQv26KgwPQ/uh ejs19gK8uHgfJipIaf65dtbsPom3bkm0aENBvxk3LF1Bl+7H30XIK2j78nnX8w9HiDnG 8h7oNWUcCHNHJ3EOL6GvzqC58rv4Gw0k/uMWDfyv+ylWNCO5KitYXFfxnovZbDVrXIWg RV8Cwp4Vf87dtnzS2l2RHmvLDFMPDnW3A36bJ/Pxgez4OpiWI9C4MMUZSLEU137B5maG VLQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=TVNUGw/2FicYi/PP7br2jI62kN7fxBS8Q/Y12Z9n1/Y=; b=NgrLJxf/ERktmK6jwbN1wr0Hxcjf/MsEI2v7syjGS5j6zs3QyUJLbeubk56jgVebnG jStTmF0Ek3sVTeeNPJIaIglfCfqwJ5vcf+mRlkdngu6ICtWVi1LZaWW3lxq4GhMEx/9U zprl8wG1fjSWD1vIimKPC2Z8pin0FyPe+gC1jGtQvZaOXVdsCrW9M+Ii+vWmfukVb0xM HA63FGZ5Ix7Srp5RTas9i1Iaa6HjsNYBIwlFZqHap4KYfXzkHHgtxif9vHOgWidGw4vf kh5gbRLzFCiNQJARWEpuoZFP1VVtkyvm9mDOgkTbN0M4BBGkVEnJNgE0ykwWgX4CU1Ip vqSw== 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 x4-v6si107952plv.166.2018.03.19.07.39.53; Mon, 19 Mar 2018 07:40:08 -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 S933396AbeCSOi5 (ORCPT + 99 others); Mon, 19 Mar 2018 10:38:57 -0400 Received: from bmailout3.hostsharing.net ([176.9.242.62]:50875 "EHLO bmailout3.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755034AbeCSOix (ORCPT ); Mon, 19 Mar 2018 10:38:53 -0400 Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (not verified)) by bmailout3.hostsharing.net (Postfix) with ESMTPS id 049F3100EEFE5; Mon, 19 Mar 2018 15:38:52 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 98BE54A9D; Mon, 19 Mar 2018 15:38:51 +0100 (CET) Date: Mon, 19 Mar 2018 15:38:51 +0100 From: Lukas Wunner To: Laura Abbott Cc: Linus Walleij , Kees Cook , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Mathias Duckeck Subject: Re: [PATCHv2 2/4] gpio: Remove VLA from MAX3191X driver Message-ID: <20180319143851.GA24209@wunner.de> References: <20180315180030.20001-1-labbott@redhat.com> <20180315180030.20001-3-labbott@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180315180030.20001-3-labbott@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 15, 2018 at 11:00:28AM -0700, 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 several a VLA with an appropriate call to > kmalloc_array. > > Signed-off-by: Laura Abbott Reviewed-and-tested-by: Lukas Wunner This one isn't a hotpath, so the kmalloc overhead is negligible. Did a quick test on a single-chip MAX31913 with no apparent issues. > --- > v2: No changes > --- > drivers/gpio/gpio-max3191x.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpio-max3191x.c b/drivers/gpio/gpio-max3191x.c > index f74b1072e84b..b5b9cb1fda50 100644 > --- a/drivers/gpio/gpio-max3191x.c > +++ b/drivers/gpio/gpio-max3191x.c > @@ -315,12 +315,17 @@ static void gpiod_set_array_single_value_cansleep(unsigned int ndescs, > struct gpio_desc **desc, > int value) > { > - int i, values[ndescs]; > + int i, *values; > + > + values = kmalloc_array(ndescs, sizeof(*values), GFP_KERNEL); > + if (!values) > + return; > > for (i = 0; i < ndescs; i++) > values[i] = value; > > gpiod_set_array_value_cansleep(ndescs, desc, values); > + kfree(values); > } > > static struct gpio_descs *devm_gpiod_get_array_optional_count( > -- > 2.14.3 >