# HG changeset patch # User Praveen Kumar Dasaraju Rama # Date 1280885550 25200 # Node ID 05a4e7665357f6ac33912b96eb1fa85e84d090fe # Parent 22e6d3edaab5b47ef334de59ec85a55d1df1ba02 6973912 pci_autoconfig: alloc_res_array() feels a little off (by one) diff -r 22e6d3edaab5 -r 05a4e7665357 usr/src/uts/intel/io/pci/pci_boot.c --- a/usr/src/uts/intel/io/pci/pci_boot.c Wed Aug 04 07:38:56 2010 +0800 +++ b/usr/src/uts/intel/io/pci/pci_boot.c Tue Aug 03 18:32:30 2010 -0700 @@ -3244,28 +3244,28 @@ static void alloc_res_array(void) { - static int array_max = 0; - int old_max; + static int array_size = 0; + int old_size; void *old_res; - if (array_max > pci_bios_maxbus + 1) + if (array_size > pci_bios_maxbus + 1) return; /* array is big enough */ - old_max = array_max; + old_size = array_size; old_res = pci_bus_res; - if (array_max == 0) - array_max = 16; /* start with a reasonable number */ - - while (array_max < pci_bios_maxbus + 1) - array_max <<= 1; + if (array_size == 0) + array_size = 16; /* start with a reasonable number */ + + while (array_size <= pci_bios_maxbus + 1) + array_size <<= 1; pci_bus_res = (struct pci_bus_resource *)kmem_zalloc( - array_max * sizeof (struct pci_bus_resource), KM_SLEEP); + array_size * sizeof (struct pci_bus_resource), KM_SLEEP); if (old_res) { /* copy content and free old array */ bcopy(old_res, pci_bus_res, - old_max * sizeof (struct pci_bus_resource)); - kmem_free(old_res, old_max * sizeof (struct pci_bus_resource)); + old_size * sizeof (struct pci_bus_resource)); + kmem_free(old_res, old_size * sizeof (struct pci_bus_resource)); } }