From patchwork Mon Apr 9 21:06:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 10332005 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 ACE866022E for ; Mon, 9 Apr 2018 21:06:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9ECAC28923 for ; Mon, 9 Apr 2018 21:06:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 938DE28BEC; Mon, 9 Apr 2018 21:06:59 +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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3206728923 for ; Mon, 9 Apr 2018 21:06:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 27D956E100; Mon, 9 Apr 2018 21:06:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by gabe.freedesktop.org (Postfix) with ESMTPS id DBF8F6E2DE for ; Mon, 9 Apr 2018 21:06:55 +0000 (UTC) Received: by mail-pf0-f196.google.com with SMTP id f15so6444734pfn.0 for ; Mon, 09 Apr 2018 14:06:55 -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; bh=JabFw4XiOs7FstGNqpfRhCpveZoXSN450e4MjJLUX78=; b=dhMZ5iRnS5FhDTQ/LgZX6/xJUHGqowNhq77doNLVr13KCYhb1nwr4Xc8pvLz/lFUY9 dpF5SI2/G0o8EJqxxneuESf54bt9Pgjn85gk2OxoKEk0GQgNx4NDvaSGjnxc7pb9h3PT J19xDjiOX5CaKk/96TScRlWUi3JC9G3kV/qZvaQhzUTKfo5ntIrqwZXRaxosnccPymJI rMS2AZwSEjMuZTEQJkmS2ULrN16lxqX68yo5x8g/z/JgulXlwhyUwtHUS/YpJ2QxQc3a kuVanfNPDAw+I6S2Jf4NZXc0qvQMGH8JrcT8p2Gn3uHhYD3Uc1Me+6vE/Fy30objDXaT nojw== X-Gm-Message-State: AElRT7FCqa1M3tQ23cEg3lWtwBaFcGi5+EzwdMV83qypwPYoRfUccIV/ QiLXrMuTsi04CYrZ4wiW9ByOpZhsi9Y= X-Google-Smtp-Source: AIpwx487YaYyDj7Bd8YK6j4Xa+i5d3tPZCIOIGunPUBOki/5VQh/XkxWmqt7C6N9Ws37LlWjZLPbBA== X-Received: by 10.101.98.90 with SMTP id q26mr26745555pgv.113.1523308015462; Mon, 09 Apr 2018 14:06:55 -0700 (PDT) Received: from labbott-redhat.redhat.com ([2601:602:9802:a8dc::1082]) by smtp.gmail.com with ESMTPSA id 195sm1916715pgd.3.2018.04.09.14.06.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Apr 2018 14:06:54 -0700 (PDT) From: Laura Abbott To: Patrik Jakobsson Subject: [PATCH] drm/gma500: Remove VLA Date: Mon, 9 Apr 2018 14:06:47 -0700 Message-Id: <20180409210647.3718-1-labbott@redhat.com> X-Mailer: git-send-email 2.14.3 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kees Cook , kernel-hardening@lists.openwall.com, David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP There's an ongoing effort to remove VLAs[1] from the kernel to eventually turn on -Wvla. Switch to a reasonable upper bound for the VLAs in the gma500 driver. [1] https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Laura Abbott Reviewed-by: Kees Cook --- This was a little hard to figure out but I think 32 should be a comfortable upper bound based on all the structures I saw. Of course I can't test it. --- drivers/gpu/drm/gma500/psb_intel_sdvo.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/gma500/psb_intel_sdvo.c b/drivers/gpu/drm/gma500/psb_intel_sdvo.c index 84507912be84..3d4fa9f6b94c 100644 --- a/drivers/gpu/drm/gma500/psb_intel_sdvo.c +++ b/drivers/gpu/drm/gma500/psb_intel_sdvo.c @@ -429,13 +429,20 @@ static const char *cmd_status_names[] = { "Scaling not supported" }; +#define MAX_ARG_LEN 32 + static bool psb_intel_sdvo_write_cmd(struct psb_intel_sdvo *psb_intel_sdvo, u8 cmd, const void *args, int args_len) { - u8 buf[args_len*2 + 2], status; - struct i2c_msg msgs[args_len + 3]; + u8 buf[MAX_ARG_LEN*2 + 2], status; + struct i2c_msg msgs[MAX_ARG_LEN + 3]; int i, ret; + if (args_len > MAX_ARG_LEN) { + DRM_ERROR("Need to increase arg length\n"); + return false; + } + psb_intel_sdvo_debug_write(psb_intel_sdvo, cmd, args, args_len); for (i = 0; i < args_len; i++) {