From patchwork Thu Mar 15 18:00:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 10285437 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 122F360386 for ; Thu, 15 Mar 2018 18:01:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02ABC28BE0 for ; Thu, 15 Mar 2018 18:01:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB4A328BE2; Thu, 15 Mar 2018 18:01:39 +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 367E328BE0 for ; Thu, 15 Mar 2018 18:01:39 +0000 (UTC) Received: (qmail 9374 invoked by uid 550); 15 Mar 2018 18:01:04 -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 9290 invoked from network); 15 Mar 2018 18:01:01 -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=BogRfGPOdj8BNG2vMq34fZkUxMAfVJNs4hyWBbuR5qg=; b=PX7NDjPLmHclMch6zOwWV9F878bnqTBRYrABJU1LrDKecdlLRkPruxyKe6WslsW6WJ NtT4fJcc+p7kzf1/i0UxBVBD+QFWvYtrxvIFhNM0czBTHl9jRqWhukDqbcnd+SLAlATx 3C70cXFSEJxNw+wtEAmn8FhHAPaU2jkBBoc6z1PeMw4Mq8ZHnG4NZxz+gxzBazAe3NJQ IwloklOG8RLPsVW3GVxe+vgG6LPI3OCxXfeRn5xoyRepJDYTuk/3QRSwB2ehaOWKXDrD yhqKa6LqiKBCwU0vlLHQGVr3SulrHZzs4TU375zi79ggdoNUa7+c+cGfDfe0cyoWbFiY CWjw== X-Gm-Message-State: AElRT7EW4nQDNetVVzcnNXZILRBhK/1xrgTzcGgdKeIdkbMrND6v13oG +CXi+EO1OHNDsBYg/BNUdns1RA== X-Google-Smtp-Source: AG47ELs8o6ilQ8Zo6q16mhydQpU2IekRivZvxNlys7E414pG6vYLS4s+gb8QCO83oFICKtUMcS5a/Q== X-Received: by 10.202.48.211 with SMTP id w202mr5462256oiw.29.1521136848326; Thu, 15 Mar 2018 11:00:48 -0700 (PDT) From: Laura Abbott To: Linus Walleij , Kees Cook , Patrice Chotard Cc: Laura Abbott , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCHv2 4/4] gpio: Remove VLA from stmpe driver Date: Thu, 15 Mar 2018 11:00:30 -0700 Message-Id: <20180315180030.20001-5-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. Signed-off-by: Laura Abbott --- v2: Switch to GFP_KERNEL. There was some discussion about if we should be doing the allocation at all but given a) the allocation is pretty small and b) we can possibly take a mutex in a called function I think this is fine. --- drivers/gpio/gpio-stmpe.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c index f8d7d1cd8488..c2bb20ace6f5 100644 --- a/drivers/gpio/gpio-stmpe.c +++ b/drivers/gpio/gpio-stmpe.c @@ -369,10 +369,14 @@ static irqreturn_t stmpe_gpio_irq(int irq, void *dev) struct stmpe *stmpe = stmpe_gpio->stmpe; u8 statmsbreg; int num_banks = DIV_ROUND_UP(stmpe->num_gpios, 8); - u8 status[num_banks]; + u8 *status; int ret; int i; + status = kmalloc_array(num_banks, sizeof(*status), GFP_KERNEL); + if (!status) + return IRQ_NONE; + /* * the stmpe_block_read() call below, imposes to set statmsbreg * with the register located at the lowest address. As STMPE1600 @@ -424,6 +428,7 @@ static irqreturn_t stmpe_gpio_irq(int irq, void *dev) } } + kfree(status); return IRQ_HANDLED; }