From patchwork Sat Mar 10 00:10:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 884061 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zyl6Z6Nxcz9sfy for ; Sat, 10 Mar 2018 11:11:50 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932633AbeCJALt (ORCPT ); Fri, 9 Mar 2018 19:11:49 -0500 Received: from mail-oi0-f67.google.com ([209.85.218.67]:35076 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932627AbeCJAKg (ORCPT ); Fri, 9 Mar 2018 19:10:36 -0500 Received: by mail-oi0-f67.google.com with SMTP id x10so8281292oig.2 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=Rt3dw/uk3Twnku068L46rMI/ySbkj7XNNVTTxGCJEL2SKgZWePXyJZ+pIag3wun3dd oAPZ2HKkpf/0uNVomyMuCFgu5dR+KKjVE9+kMgPxFIVdvhh0qc7gSR7KLywhoJE90wtA oQhrKxPsHWV3N1T/wZX1XYyjmF6A2cbf8QkcZxYpU7aw9EfMKU6YV0bxgEV2HeZ4lC3C A4sv+QjeGit4B0YL0Fq64RgZUTa739R3v89b5h+W8LBfw7OZh4dnVpG9xfo8pLis9yaU bDFu9jU2sDJTonOhR7yoYrcNuHoqU9644nCKAxrUkDB1y0BdWWVP95tjjE3Rkhgy9mAS XxLQ== X-Gm-Message-State: AElRT7G5vWhGR61XMJwbbzI3iUT2guif8/nsFK3vGsX496Y/HRS0n+MT qWnuYiGbqQLljCY76nvC8nWQtA== X-Google-Smtp-Source: AG47ELtmSv7r9PaZS2MrGkgpU3k1TQTzASl9NlrX8S4vN45UfyElI9Ff4pntq4knqUpQF5/X25553g== 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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@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(