From patchwork Sat Mar 10 00:10:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 10272613 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2AE8F60594 for ; Sat, 10 Mar 2018 00:11:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 198BB2A057 for ; Sat, 10 Mar 2018 00:11:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C8662A056; Sat, 10 Mar 2018 00:11:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 01B532A046 for ; Sat, 10 Mar 2018 00:11:11 +0000 (UTC) Received: (qmail 24448 invoked by uid 550); 10 Mar 2018 00:10:51 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 24358 invoked from network); 10 Mar 2018 00:10:49 -0000 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=17zt0Sf3Wd3XozX5xGu4WLBb9pLFNLfrxbzuq8iiG7g=; b=rr2XdEgRE40AZJawFYaS4RlWaHhCaufNrVkHlTftEexWAh4kCwggc8Nl5y8UTCnNfk +yAsnM/XYQSh345U9rbz6SnSqP9o98hdezQwMWWnqTEH5cecXYBWy1RfQHCRuKC2rlMM 7M2cGY5gxwvgRDuRRu+p1nqkMNV2umcDKHgHTF38AtWevYXs94Rh5Jh41Q1t2G+/xJWH tQQgbTP6SmYQMQHI49//J7e95SVH2luF2yXNlPrG5Pmvde+g8tiD7Nn5Rm1El++uwbko afQ8aWyinl5yjuRp+6P0+ykxZEOMsZMnXPXBz032wOzssYjpmfZ0a7GtzEKq8zBCh2aC z6rA== X-Gm-Message-State: AElRT7HZJQmqovxyCSkgiQrwCTaEbvIkAsW59T2e7mTDeHtNU+pRjWVr hAwGQZoORMOn1vA77Btl5WWf7g== X-Google-Smtp-Source: AG47ELtgqDInEa+E1Zo8RZ4HhXqTbuU9OYS+4nAvJ+YSn6qPsUGap1jrY5fox/qYpBAabIes49qL/Q== X-Received: by 10.202.229.11 with SMTP id c11mr161986oih.193.1520640638258; Fri, 09 Mar 2018 16:10:38 -0800 (PST) From: Laura Abbott To: Linus Walleij , Kees Cook , Nandor Han , Semi Malinen Cc: Laura Abbott , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCH 3/4] gpio: Remove VLA from xra1403 driver Date: Fri, 9 Mar 2018 16:10:20 -0800 Message-Id: <20180310001021.6437-4-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> X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Nandor Han --- drivers/gpio/gpio-xra1403.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-xra1403.c b/drivers/gpio/gpio-xra1403.c index 0230e4b7a2fb..8d4c8e99b251 100644 --- 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]; + int *value; int i; unsigned int gcr; unsigned int gsr; + value = kmalloc_array(xra1403_regmap_cfg.max_register, sizeof(*value), + GFP_KERNEL); + if (!value) + return; + seq_puts(s, "xra reg:"); for (reg = 0; reg <= xra1403_regmap_cfg.max_register; reg++) seq_printf(s, " %2.2x", reg); @@ -154,6 +159,7 @@ static void xra1403_dbg_show(struct seq_file *s, struct gpio_chip *chip) (gcr & BIT(i)) ? "in" : "out", (gsr & BIT(i)) ? "hi" : "lo"); } + kfree(value); } #else #define xra1403_dbg_show NULL