Received: by 10.213.65.68 with SMTP id h4csp111222imn; Thu, 15 Mar 2018 11:05:36 -0700 (PDT) X-Google-Smtp-Source: AG47ELuIITr4iI95EvUGo4z+g8rrZOVvW1a+J9T+7JVLVP42K5/PuoZMyQG6vnqMtRncPoP/audJ X-Received: by 10.101.81.133 with SMTP id h5mr7398588pgq.188.1521137136824; Thu, 15 Mar 2018 11:05:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521137136; cv=none; d=google.com; s=arc-20160816; b=HixCzXVVuzqSrQaf9eavSfXewVWwwKslsazub9QospzHBP3l2d4yGrSoe/pwi1oHPo CDe3JNY1EQITX3MSf7GyAbu9+KbQeOQztfEQMzUpw+iqArxzsQBqc1ZNTd4H3KaDN/TY 4M6opcpB1seZ489N0Ghmihb7b2OcfeRTIA9u2eIvERqC9dkgRF7z5RR/US5Hc16C7lN+ ZjGWBm7vxLi+PPq6LAp5JnQSO9wGXicZE7s434onBIle+Qa+f2CQzjoF+tPNXmOE+qvH rxqtWjBVCro2R+cWostAYcgp9pXuI0mPk5Y8j143RywnBOrmpGEFGv2pftz1MaA+16wH lNsQ== 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=BogRfGPOdj8BNG2vMq34fZkUxMAfVJNs4hyWBbuR5qg=; b=JN5UrGJxt6I/bJ8DOrUzoc9dG/ok3NPS5wTLORvzR/6JfyMGv3ZWBFZlEP43wpuwz5 Wpp4oSkZBSshvJvVSUo9JgJpy8LT5hrNtDjWg8cIJsRw3DJ6a7GcHLWWuFaIZK05ZvNJ +RlS6i77SEdTz32oVa4FXnGpzosEbtLgFklqHlNufdksAKxp0MmBri71XIZKlVIc3rYU lTOWTCSnkoUSDQBab0cQhK3KHaZgadtxafAzxRD5yvKIbUo2fP0dEoGUr3wt7ER3/yxl 3SLzh5fCWrIPPkww5FCDR6hxuyeNB6A12r7GAWBj4YkqF1nZSiEqPC2nTQXZdicldMLV FAHQ== 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 u10-v6si4277794plu.362.2018.03.15.11.04.51; Thu, 15 Mar 2018 11:05:36 -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 S932469AbeCOSAx (ORCPT + 99 others); Thu, 15 Mar 2018 14:00:53 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:34571 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932443AbeCOSAu (ORCPT ); Thu, 15 Mar 2018 14:00:50 -0400 Received: by mail-oi0-f68.google.com with SMTP id e79so2503405oih.1 for ; Thu, 15 Mar 2018 11:00:49 -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=BogRfGPOdj8BNG2vMq34fZkUxMAfVJNs4hyWBbuR5qg=; b=KKXnK4sfuoANqUNDjg63yfR9ox2gU7/uAj8RSulMDcxHiSWNq+xJlZjw9FvK57yKoV 5ttpjbCoklmoU6kqg+yf1V7VnKaRLO3lfOBSLj+JTQ8HXE9KisXZkk2FESIjI6FoTBgC 2HY/9tWqFEcD9j0w6B8M91nvRwx5YeaHtmUe5UMLoPQ3O6UuCE5qGgC0Tses5u7/u/Up q+xMeNr91VPCO5bBpfvZGrJ01vp4a5OyIE9Q4V6ZfyRfBU52VisWXmZgfn8uqu6SKf7G AHHRT/zqnfrg6AHR+JrP4kEUMek2eildBgTk1S6gttMq5lUEnctiiOJ1zhndqCvI1wuc pKjA== X-Gm-Message-State: AElRT7GGFJVGTCxhkHJQccg/5wIgT4R9CJ6lcKvZevQ+5rqgKRIyEwQh nZe2UR5RUDVLgkTUOOllytSjYw== X-Received: by 10.202.48.211 with SMTP id w202mr5462256oiw.29.1521136848326; Thu, 15 Mar 2018 11:00:48 -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.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Mar 2018 11:00:46 -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> 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. 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; } -- 2.14.3