Received: from mout.kundenserver.de ([212.227.126.131]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gAJUc-0006Ef-B8 for linux-mtd@lists.infradead.org; Wed, 10 Oct 2018 18:46:00 +0000 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> List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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(-) 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. */ -- 2.18.0