From patchwork Wed Apr 11 01:04:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 10334703 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 9AA5B6053C for ; Wed, 11 Apr 2018 01:04:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99B2726253 for ; Wed, 11 Apr 2018 01:04:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DA6D285DB; Wed, 11 Apr 2018 01:04:37 +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=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 A09DE26253 for ; Wed, 11 Apr 2018 01:04:36 +0000 (UTC) Received: (qmail 10060 invoked by uid 550); 11 Apr 2018 01:04:33 -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 9980 invoked from network); 11 Apr 2018 01:04:32 -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; bh=wKq7BowXlYKx0270E2z2yatGRuasNAfpSUqQlX2oZu4=; b=QMsmCOqo9510KFWFmScglDb8kf3p+XT1sEy6Mc34R5hBwUfJt0Wl0NLvjj8OI2IO20 YGJ2FEmVehimAMsRDMMHbIwJCH/DyDKvoeo7pSDhwzxgTjhL2RGEchnLOLNnRUb1OIrS k6D3Ye9CXn2JzwgU8BD5vWnuGiiFL0ymkm/G5kIN7om+e1e5pPMlo7wav0yW0IaF/NLV dcf0WqWPpgfk56TqUj7Mqg+mmOOaVp6aRy/g6xofBzCd+bmkKQySuC88p4t1t8y1j48B kMiHcTYVhu2JKLd56S0Bg0nQyG6M4/6KAQZbaXJmZPQeQg5HqgRW9QLdCdvr6RvRM0T9 pyAw== X-Gm-Message-State: ALQs6tCE6lXd1by/f9Grdj3ivIXps7JSrFI8x0uoTM1FTF5Y/kpmaRwB tD17bw/G5KBeGnZ0aIXJ7pdHEg== X-Google-Smtp-Source: AIpwx4+XE3jvUUwDfmT4F2jFTikZpf1loC6n57/m2RSSyQfucmrEYZEIx3VP0X3QoSC6QEAVovJSmw== X-Received: by 2002:a17:902:4d45:: with SMTP id o5-v6mr2807661plh.84.1523408661291; Tue, 10 Apr 2018 18:04:21 -0700 (PDT) From: Laura Abbott To: Alex Dubov , Arnd Bergmann , Greg Kroah-Hartman Cc: Laura Abbott , linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCHv2] misc: tifm: Remove VLA Date: Tue, 10 Apr 2018 18:04:12 -0700 Message-Id: <20180411010412.18006-1-labbott@redhat.com> X-Mailer: git-send-email 2.14.3 X-Virus-Scanned: ClamAV using ClamSMTP There's an ongoing effort to remove VLAs[1] from the kernel to eventually turn on -Wvla. The single VLA can either take a value of 2 or 4 so switch to the upper bound. [1] https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Laura Abbott Acked-by: Arnd Bergmann --- v2: Add extra bounds check per request of Arnd --- drivers/misc/tifm_7xx1.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/misc/tifm_7xx1.c b/drivers/misc/tifm_7xx1.c index e5f108713dd8..9ac95b48ef92 100644 --- a/drivers/misc/tifm_7xx1.c +++ b/drivers/misc/tifm_7xx1.c @@ -239,9 +239,13 @@ static int tifm_7xx1_resume(struct pci_dev *dev) unsigned long timeout; unsigned int good_sockets = 0, bad_sockets = 0; unsigned long flags; - unsigned char new_ids[fm->num_sockets]; + /* Maximum number of entries is 4 */ + unsigned char new_ids[4]; DECLARE_COMPLETION_ONSTACK(finish_resume); + if (WARN_ON(fm->num_sockets > ARRAY_SIZE(new_ids))) + return -ENXIO; + pci_set_power_state(dev, PCI_D0); pci_restore_state(dev); rc = pci_enable_device(dev);