From bb6e299ccbeb4c042c9922ddc3035eab38926303 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 4 Dec 2013 09:48:36 +0100 Subject: [PATCH] * grub-core/kern/i386/qemu/init.c: Remove variable length arrays. --- ChangeLog | 4 ++++ grub-core/kern/i386/qemu/init.c | 21 ++++++--------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 38e128462..277258148 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-12-04 Vladimir Serbinenko + + * grub-core/kern/i386/qemu/init.c: Remove variable length arrays. + 2013-12-04 Vladimir Serbinenko * include/grub/types.h: Declare all byteswaps as inline functions diff --git a/grub-core/kern/i386/qemu/init.c b/grub-core/kern/i386/qemu/init.c index e05ccee96..09da1e97f 100644 --- a/grub-core/kern/i386/qemu/init.c +++ b/grub-core/kern/i386/qemu/init.c @@ -96,17 +96,8 @@ struct iterator_ctx grub_size_t nresources; }; -static int -count_cards (grub_pci_device_t dev __attribute__ ((unused)), - grub_pci_id_t pciid __attribute__ ((unused)), - void *data) -{ - int *cnt = data; - - (*cnt)++; - - return 0; -} +/* We don't support bridges, so can't have more than 32 devices. */ +#define MAX_DEVICES 32 static int find_resources (grub_pci_device_t dev, @@ -116,6 +107,9 @@ find_resources (grub_pci_device_t dev, struct iterator_ctx *ctx = data; int bar; + if (ctx->nresources >= MAX_DEVICES * 6) + return 1; + for (bar = 0; bar < 6; bar++) { grub_pci_address_t addr; @@ -190,13 +184,10 @@ enable_cards (grub_pci_device_t dev, static void grub_pci_assign_addresses (void) { - int ncards = 0; struct iterator_ctx ctx; - grub_pci_iterate (count_cards, &ncards); - { - struct resource resources[ncards * 6]; + struct resource resources[MAX_DEVICES * 6]; int done; unsigned i; ctx.nresources = 0;