From patchwork Sat Mar 10 00:10:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 10272615 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 554DD6016D for ; Sat, 10 Mar 2018 00:11:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 424FC2A045 for ; Sat, 10 Mar 2018 00:11:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36C352A044; Sat, 10 Mar 2018 00:11: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 5E9642A055 for ; Sat, 10 Mar 2018 00:11:19 +0000 (UTC) Received: (qmail 24517 invoked by uid 550); 10 Mar 2018 00:10:54 -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 24451 invoked from network); 10 Mar 2018 00:10:51 -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=Kjh2dRWQC3XfvJzP9sKUndnJx1a6KsrfaacoJ+FnTYk=; b=fsJ9zrP8jAR3qKKILSczCc+zqbbFm02eu7/drGQJzpbCQu2nTPcHdNNc8/qxqbRDZC 07AK0ZB/7+dAK9mFQopvtxGPqh4p6ghgfkBeNAwoDNAts4iVk+C/eYZYH7TU7Jiv2qV5 NJ97nykHpmrAQCyYqnoNZ8Cz5xupgnx7UYuDykiYXDoDMe/YeVZ6+NBSDMzXLZgEYzZE mNHyDZlAuXsepX4FQKhXtfvkKKlvxknv9qcs4R+KPJDVeSQSf7SYxxGkhLtEJybpES4W bs5Ll/Vdq9ToSw6OdNzfIM6Dw/x49zJBO1unqBNlu6YYdoNGwIkFTQBRACQx4jqS+UIq 9xTA== X-Gm-Message-State: AElRT7EVYCma8DXWqgBeigiP/Ojy5TZUEy21vb+7lV0gt7KsAG5lmQRF UtIBCexJwvVN1vBmUYQV4ZUh4w== X-Google-Smtp-Source: AG47ELvCX1zITyaJO2g7SHnyoiCPpzL699x/UwpEhoT0MbYxILctz42QBq6Sl5/fg+ToQJ4Uip200Q== X-Received: by 10.202.56.87 with SMTP id f84mr172611oia.254.1520640640318; Fri, 09 Mar 2018 16:10:40 -0800 (PST) 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: [PATCH 4/4] gpio: Remove VLA from stmpe driver Date: Fri, 9 Mar 2018 16:10:21 -0800 Message-Id: <20180310001021.6437-5-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> 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 --- 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..b7854850bcdb 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_ATOMIC); + 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; }