Received: by 10.213.65.68 with SMTP id h4csp110195imn; Thu, 15 Mar 2018 11:03:41 -0700 (PDT) X-Google-Smtp-Source: AG47ELv9AeLGMJRSEMGDsAtW2uudnFsvymH+TCD+DxbsNl0Pg9+0bkWKgpNE+xG8Xhdqkihfc5qQ X-Received: by 2002:a17:902:9a4a:: with SMTP id x10-v6mr9358296plv.256.1521137021579; Thu, 15 Mar 2018 11:03:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521137021; cv=none; d=google.com; s=arc-20160816; b=n850YKPRH5zbXMBK1uqEHDGAOS2nAqyuHQdHbl+2M2dSVGnJUqEwOjxVRbHjKHp6M4 zWt5CyZgiFCNxCTI+0LPovPljTY/zMcmH1lLuAlpphmeggskR1SxlVo9WYaZd0/bTdZ5 fx5NpoIUm+VSzVn0HCzwFAX6Y6eamTo9NAoC6jAHYnnMqt/YfAspfjN5ydkNr0ObUNji gkHKD+yB0LcANriaOkffQX9OR6S/cgxtdMHSNyYF/jEyhmTE0vPAr+jWbDSg+pPGWs5n hHLlsXaJg7MSE5NYyucpP3m1WvGi69HFmz12zm7EKfY69yQxOSLAK4VjeR1O5J8rxwK1 O71g== 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=OJRRUYXa2nf7MtQGjeAPzjgvCAFxixxF/zHKjjjHHig=; b=GRN+1XiiKKXPq4jTK6zhElq+1gXR2d+vjNownfQDOfJhVfbMkB3ZDPjK8O/Lglv3GH AQg44mUTmrFd4xqNeOqA3InCO4utyYEOozlzjqGd7XFMkQTTRmbIt8OMwWmFlS8RLPtN LAGWmNDdy1PdwbbFPfZdv+OFdGTcqKKXhlzUiG1PzSr6Aycd1xLuc8f+1IxOAOZWAUr1 018Wrws2y/5uUDQg//7vMuav4vr28zBQnN77iceRm5Q8rVbg8fi/iG0u+YBo0VCLj1NO IK1xpb5We4etw/lAVCZyXSxeKlPfYDhSiX0HTiQMK+4nGYqF9h9oovRiFv7jIR/rC7+8 bAIA== 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 e2-v6si4560954pls.160.2018.03.15.11.03.13; Thu, 15 Mar 2018 11:03:41 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932495AbeCOSBP (ORCPT + 99 others); Thu, 15 Mar 2018 14:01:15 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:44690 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752700AbeCOSAs (ORCPT ); Thu, 15 Mar 2018 14:00:48 -0400 Received: by mail-oi0-f67.google.com with SMTP id b8so6444703oib.11 for ; Thu, 15 Mar 2018 11:00:47 -0700 (PDT) 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=g0MZCZWsLtcfn4F9D2RVYvY4lnpswvy2hOmhc9dFzUbmrpvuJtCALsRIPYhyr1hb3F 5eL8ySP8EDQVpf+KruQ/OlIEaHgHi9oGn55IejiPPQp9WEQRRyaJ+/5N4N1s6KiXGXq/ KgBW3I5n2eEfs0RFIxW+kSgcIadQIFU4jeNFIF2L78Hi0H9ZAxzY7p0Py8LsdhT/zvl+ llHlfL6sKEIN2fN2TWf8wiQ0TS5EUXw1Pw5w0P3FcF8QkeajWqqaTVmegkXUmEL1zPGi 5k9ZfuyiE0/I4UPcpe4D4E51GQg5GPUR7G90IZOJ465rGZHgbNGxjvuEwEsjJplCr6To KmOA== X-Gm-Message-State: AElRT7H8DaZRf263OI8r8hkTga5VvsA0tAvQXMA5qosdTaNiyEh3vzYD HiSyP0LX/L+ml3nDx6BmnL9xZw== X-Received: by 10.202.253.19 with SMTP id b19mr5406600oii.321.1521136845877; Thu, 15 Mar 2018 11:00:45 -0700 (PDT) Received: from labbott-redhat.redhat.com ([2601:602:9802:a8dc::b761]) by smtp.gmail.com with ESMTPSA id 68sm1372098otj.34.2018.03.15.11.00.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Mar 2018 11:00:44 -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> 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 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 -- 2.14.3