From patchwork Thu Mar 15 18:00:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 10285435 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 EAFD260386 for ; Thu, 15 Mar 2018 18:01:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC0B628BDF for ; Thu, 15 Mar 2018 18:01:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D083128BE1; Thu, 15 Mar 2018 18:01:29 +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 D971228BDF for ; Thu, 15 Mar 2018 18:01:28 +0000 (UTC) Received: (qmail 9286 invoked by uid 550); 15 Mar 2018 18:01:00 -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 9220 invoked from network); 15 Mar 2018 18:00:58 -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=OJRRUYXa2nf7MtQGjeAPzjgvCAFxixxF/zHKjjjHHig=; b=Xt0kH+1mBHESovdpTEMcZ4D7Otngs/luzaWd7OY/5y7ni9zORDlfOFhDHk8O6strxl koaNoRkHpTXzit0xZOVRBCW662vIgdJidLFkoFoRJHtjPFMyZ8QAiygOdNUqaU/yZt0T RX+3n8GiFkAjMIYGmgGGu7R4axNpX77j1OLgoBXT9u9bApfwpX2jYrYgb89J+fHJ+YLX S2F9CYg/srTcrRHmXW3ZW5O1nXOHJ8GdowtA5jgKVwXvSPfWsyhnd2lBErMxHc8kdsrM VzVC4bhQvaVrFD5Y6EiRagyIIAlMPjFIUBAtDD0lJ6b3XdwXYzVCQ7zgL6N38r3y/Gjk FG3w== X-Gm-Message-State: AElRT7HbwREoh3OydonQybkcMz9SicS6zkALYV4bVJI1D/o5YH9hyr2x Q25bNMjeV+tb59oD5hR8H2C8LA== X-Google-Smtp-Source: AG47ELvOj/N9AupjO7AbNSGJUEL/k1c/4kiH3a2OudH2q8+7p4pB5rhCDv9Av7YHUY8mP1z5sMDs5w== X-Received: by 10.202.253.19 with SMTP id b19mr5406600oii.321.1521136845877; Thu, 15 Mar 2018 11:00:45 -0700 (PDT) From: Laura Abbott To: Linus Walleij , Kees Cook , Nandor Han Cc: Laura Abbott , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCHv2 3/4] gpio: Remove VLA from xra1403 driver Date: Thu, 15 Mar 2018 11:00:29 -0700 Message-Id: <20180315180030.20001-4-labbott@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180315180030.20001-1-labbott@redhat.com> References: <20180315180030.20001-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. Reviewed-by: Nandor Han Signed-off-by: Laura Abbott --- v3: Add reviwed-by --- 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