From patchwork Wed Oct 10 18:44:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 148576 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1208405lji; Wed, 10 Oct 2018 11:46:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV60/EEE5CR9GMa7dYnnB2kHr3PUPHtgh40rb+QlvQrpxuNqEh0PqlkpsNN1gjhCl41KDHMsT X-Received: by 2002:a63:de05:: with SMTP id f5-v6mr30412622pgg.292.1539197177249; Wed, 10 Oct 2018 11:46:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539197177; cv=none; d=google.com; s=arc-20160816; b=BSahd5pZk7YYBXNC8hyKvaFD3hIQakpqdPSkrscG0TIan0Aso/oftoZCHTf1S8XrsI aSsbmeQ/Ro9WhDfZf/uutBX/HWLvKpWksmnO/TOJjxaMWAc2Ao1Ni6nH393Wya6VHrWp 0LRgbYksDmOlfxLpbuSPMvNhtTS/qNjygWLSHh3LgpvuxYDX3kWP34u8sdULaSL4xmob IUKrfcWTF+NC3tNNXG4Z5QUOVc8eaHvBPlQ0bZ9q/BQzDhORXpAd3YB9NcH4W0apPlPa c0LUyDdPxBKZ8RNT1XQcevJaoAIGAoUCuHzNzKXM9Syl/UGP2tTpI+RHAbSVH9nVZH9J XP8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=NGaatimjGrdKZIXTjpM0T5X2ZBHcYgmg07d6P9am4Eo=; b=tRLqiGbH5RwptjTUtAyHJqOmxne034gXR0tAkRoeirkovR/Qi6sMy84O2qg/jF8+UL +bp0EGNwMRf8K/nRaW+exH9gA7WVHpTEY8t2eNtO8Tjc5OnMFkgMp1uuCpcPni2r8iFN bCIy24OX7yOdYB9ZhnMhlgc+TtMyumu9A+TBLhZfOR8AmJ2PDdYbmFRmJo3XqoFF3/su PT8OiAudigXnnExJajMrVzqAfayCQIAaVk6kZ6isZawwC2nAQhNSBVB2L4rKeeN57lLC /a+ojjOveQCWHYeApZ/F22wsZ7gWRrrsxt100FijtUBtiAw7BlCqloAO48ZuzsYTckkY 9O4w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3-v6si25309136pld.329.2018.10.10.11.46.16; Wed, 10 Oct 2018 11:46:17 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727082AbeJKCJj (ORCPT + 32 others); Wed, 10 Oct 2018 22:09:39 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:53143 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726846AbeJKCJj (ORCPT ); Wed, 10 Oct 2018 22:09:39 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0MIUU3-1g6jmx0dlH-004Cbx; Wed, 10 Oct 2018 20:45:36 +0200 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0MIUU3-1g6jmx0dlH-004Cbx; Wed, 10 Oct 2018 20:45:36 +0200 From: Arnd Bergmann To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger Cc: Arnd Bergmann , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] mtd: sa1100: avoid VLA in sa1100_setup_mtd Date: Wed, 10 Oct 2018 20:44:50 +0200 Message-Id: <20181010184533.691620-1-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 X-Provags-ID: V03:K1:pHuP1hkqhMn8MKatBeMm63W7WEVioT9BzTTRBWh4fdDIu1/1sl3 0S7NXZ6D7ybiznN6tkwS8FrnE1Q+KEWhDVtTuenuj0pc5cG88o1OYdJcjmzcmlAGK969VQ3 9LpVBa6Vt88Siot4ABrLhhqoUeC5d9sgImpC7Y9gCcOOLHTzQ031XZWltDTK6H6MI2kn3zm 3UGiaP5fNE2ML5H38z4Ew== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V01:K0:VSaFjMSoa4M=:7C4ybR+/wN58XbM+2Xs8Pa gPVBmATlklcrx5ks+mTcK/tIGMY4Ywu9j6xLjaxOqo6tluyYTgStn/OqrJggxIT7cI69EAfxx 8/NSMZX+idTxT0Hyk9I3iARDK4uo7tk/kLyuDAjsD0iFXbOgnLa5aSl7D1GjSCqyDubPm/lwU o6KEy0xniCaG6uB13Vsy2YTxbO1IETANy66M6tEEedjjBo3m+0SpkRde2gC5Rad8hBOlyDnTN gBSeR/l5l/3f5UCRNgg/AqJ4OAbMqG9AZERtyMPVi6ExXs7OScfvtaIpWyxIj8W1vfm8UbzMR haVy8W257gcQFiETcpaKQAbvtw34yayjiyz3aFpstjirwWuRkg0isqomFRY1bfhdyK7ymmCMU 7PRokdVNBCltDltAFiBDedVfge6eBDryy1yHWLchQAt1bxE4IbraNRDoIaCqbk39+GN3y5CrI CDS3bW6s0h59V0WDiKd0ro7GN2XAhHhHPGlOdRlyyoqK2dsMDpkRZr3Qam/IR9E1+XSv4x7BW h5cj3nkCot7+w5DkFtbNPAer/m+egA/mC40nhvOKI9cNkhRPXkZN6f+CHv321jNGr+aFq1aCp FiUyjMxspS5P5AAMR/hiVIxhfGj3goG3wvFbuDeIeLQv7k5greH7kPoQtyObeGxijFTzARJ9l mkJG9HDZIdzU4N+rN45t+s1wHLINPc4s5W7I0qAJUFB4W1yXSM9obn1XRrNGF53bb9/k= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enabling -Wvla found another variable-length array with randconfig testing: drivers/mtd/maps/sa1100-flash.c: In function 'sa1100_setup_mtd': drivers/mtd/maps/sa1100-flash.c:224:10: error: ISO C90 forbids variable length array 'cdev' [-Werror=vla] As far as I can tell, there is an upper bound on the number of resources that can be passed, based on the number of CS lines on the bus. In practice, all boards we support have either one or two resources, but using six to be on the safe side has no extra cost. Signed-off-by: Arnd Bergmann --- drivers/mtd/maps/sa1100-flash.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.18.0 Reported-by: Arnd Bergmann diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c index 784c6e1a0391..234573b401bd 100644 --- a/drivers/mtd/maps/sa1100-flash.c +++ b/drivers/mtd/maps/sa1100-flash.c @@ -23,6 +23,8 @@ #include #include +#define SA1100_NUM_CS 6 + struct sa_subdev_info { char name[16]; struct map_info map; @@ -157,7 +159,7 @@ static struct sa_info *sa1100_setup_mtd(struct platform_device *pdev, /* * Count number of devices. */ - for (nr = 0; ; nr++) + for (nr = 0; nr < SA1100_NUM_CS; nr++) if (!platform_get_resource(pdev, IORESOURCE_MEM, nr)) break; @@ -221,7 +223,7 @@ static struct sa_info *sa1100_setup_mtd(struct platform_device *pdev, info->mtd = info->subdev[0].mtd; ret = 0; } else if (info->num_subdev > 1) { - struct mtd_info *cdev[nr]; + struct mtd_info *cdev[SA1100_NUM_CS]; /* * We detected multiple devices. Concatenate them together. */