From patchwork Thu Mar 15 18:00:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 10285431 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 E16FF60291 for ; Thu, 15 Mar 2018 18:01:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D134728BE1 for ; Thu, 15 Mar 2018 18:01:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5C4728BE2; Thu, 15 Mar 2018 18:01:20 +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 1307E28BDF for ; Thu, 15 Mar 2018 18:01:19 +0000 (UTC) Received: (qmail 9249 invoked by uid 550); 15 Mar 2018 18:00:59 -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 8007 invoked from network); 15 Mar 2018 18:00:55 -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=NPn+bd/tFVjdueEmk5C7pFyl4Z5oi6dsiT5tuveRGEc=; b=VHWHynpVm+gUgzi3gFDJBFRoG1dxby9zLuGbnDHyotLj0141Sooyi5zZFLj3TnKksI onikrXf8ZB0s6tYrLCq8iPiYoVDxbeYef6JW46z2RIjtmthvrqBisfxAOUcefw6U6+ik /S2aaENXFD/x0qbARuRitL+zSiIgZFYMzjZUMA50SduuLxHxEDsB82bQgfovVuYCJwOu rZ8W6IAPbkrHwrRDMza4nlWeYOF/BXqFlIXRQN50uN9bIQrBk1K8t+3sT7XoEg8r/tAh +h4UelsWXIUei1FncMnZfk+xeXb3UYdIwLLflF7vH+Q0501a/V84Hte1nBwr/ncyknmr JmMA== X-Gm-Message-State: AElRT7EC1Atlne2Y5YU5bv0jCM8eNS34k3gQ3kn4e87beBqn7Uh1TB63 zG5VvvbLLO65rsBuu+zz85/8lSRNyZQ= X-Google-Smtp-Source: AG47ELs+r32LEPutctlKaxTgovPdaVz2jhwYd+SqlAWzbfn8J0euNpNt+A9ydADS98GBg/U3sTBEDA== X-Received: by 10.84.67.153 with SMTP id u25mr6071124oiv.339.1521136843252; Thu, 15 Mar 2018 11:00:43 -0700 (PDT) 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: [PATCHv2 2/4] gpio: Remove VLA from MAX3191X driver Date: Thu, 15 Mar 2018 11:00:28 -0700 Message-Id: <20180315180030.20001-3-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 several a VLA with an appropriate call to kmalloc_array. Signed-off-by: Laura Abbott --- v2: No changes --- 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(