Received: by 10.223.185.111 with SMTP id b44csp893500wrg; Fri, 9 Mar 2018 16:12:50 -0800 (PST) X-Google-Smtp-Source: AG47ELsV+4rQCl512kKUFFS/AB6H7u8S5nwvkFH5KEJ+o5Ce+KlgYe4/qd/M1fbqn+uDMlPl/nUw X-Received: by 10.99.117.83 with SMTP id f19mr253673pgn.318.1520640770126; Fri, 09 Mar 2018 16:12:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520640770; cv=none; d=google.com; s=arc-20160816; b=VSNMkILL9tRjpKL4c987xXtF9sKcWEUM5PnT4ehkFqKut7GrPo2FMfoyzMWEUEb7Fd u+7xb3A2mmuenH1C6OfAgswMCjWTEHTAKnIL8Xm+vN8XHrxMq3owgGd8AZPy5lH3a3Gx 1/UNrhuyRrl8i0kNb1iL1kSc7KqcWW5Ry18p7iJATE2Eyf3bcdIr9/B4vUO4UfhEKACe SPylrluFJtEnramSOwk4MbpPc2Ah9FYJeADkwcOq1nPG3LpTLr3No8/EPSFzWTXhccuY zTMJ9xaAhYWIvYCI3e9U3uRltZyeqWkLEEcuDaTaIQ2nrkDfn9hminQ1jdAz65Oy5J6/ xxqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=474AYZ35G8oYHx5uigfs25WvIcdFL+8l79GX75PnAwU=; b=X6B4oM4MA3afHS5Nb1HrU0tggg/aV9emlLYDASEdpxGJqsCrlaemCtTvgn1Df5BYFB qaToGwiD/OW0ilqDWCPWdwCSn+rTrHD9D7bk+RgSOLsdyw7ZThYF8SqeGE2g39RTHmX2 eTao8ZYHedJ8KWOj/LaEf/axQvlXA606VHd3IDlR3pW+OSYi2X1lr22p34/l+Z3KbxdD IPvP22T+JItTe242ntBzlt5EsKy9Y4Z3yPHfdLSddmaxRw5XnzKjSgFGtZ28c75MlRlW etMS1EA42btWoKTnR+PVsgQSqzY2DFYQpPyBGmS2ONzpMDvANTgXStsa60PdiA8/MnLe QTcQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2-v6si1722616ple.387.2018.03.09.16.12.32; Fri, 09 Mar 2018 16:12:50 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932890AbeCJALV (ORCPT + 99 others); Fri, 9 Mar 2018 19:11:21 -0500 Received: from mail-oi0-f66.google.com ([209.85.218.66]:43124 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932633AbeCJAKg (ORCPT ); Fri, 9 Mar 2018 19:10:36 -0500 Received: by mail-oi0-f66.google.com with SMTP id a207so8266495oii.10 for ; Fri, 09 Mar 2018 16:10:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=474AYZ35G8oYHx5uigfs25WvIcdFL+8l79GX75PnAwU=; b=eezTz4WLZlh+iOos/jWuLQfdl0w9gQv8IwHcCox1koaUUyCrAfiIe65H2/WmHe9qxf G9i10hi+Q+8p1RJw6xVHryYvJVoxvjGQ8LJWdtr70IQc++Vt6/vrxvGCbCY8DLYue5LB Tdzj3MIoVUmo+CXus/0WajHZ8zgVoF1LhY2jNoVYdMdv+BzfSZy76eWOALSIOlwG9Avi kHT25X7G0lGMUaGq8frSJ53td2yBtbXE/BrJ6ruSYLkhtd6QzCnfhmgfGkUrEz4F08W/ JFRzMbOHMeX8ABK2+cIeLz4hBXoBSolpbpk48ThoOk3ZesdnrolMhaulj4ug6CS45Zhb kA0Q== X-Gm-Message-State: AElRT7GqHfWm+DBt+L2pLRgDQFNdUxMrG1OJwAAqKfi2mYEK+Og4f6Mp cRQ+l0SPFLyLIG7ZguzJp5XMRg== X-Received: by 10.202.16.14 with SMTP id 14mr153290oiq.341.1520640636235; Fri, 09 Mar 2018 16:10:36 -0800 (PST) Received: from labbott-redhat.redhat.com ([2601:602:9802:a8dc:4eb2:6dae:ab32:e5b0]) by smtp.gmail.com with ESMTPSA id s12sm1007076oie.9.2018.03.09.16.10.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Mar 2018 16:10:35 -0800 (PST) From: Laura Abbott To: Linus Walleij , Kees Cook , Lukas Wunner Cc: Laura Abbott , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Mathias Duckeck Subject: [PATCH 2/4] gpio: Remove VLA from MAX3191X driver Date: Fri, 9 Mar 2018 16:10:19 -0800 Message-Id: <20180310001021.6437-3-labbott@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180310001021.6437-1-labbott@redhat.com> References: <20180310001021.6437-1-labbott@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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