]> git.karo-electronics.de Git - linux-beck.git/commitdiff
powerpc: Remove alloc_maybe_bootmem for zalloc version
authorMilton Miller <miltonm@bga.com>
Tue, 10 May 2011 19:29:24 +0000 (19:29 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Thu, 19 May 2011 05:30:57 +0000 (15:30 +1000)
Replace all remaining callers of alloc_maybe_bootmem with
zalloc_maybe_bootmem.   The callsite in pci_dn is followed with a
memset to clear the memory, and not zeroing at the other callsites
in the celleb fake pci code could lead to following uninitialized
memory as pointers or even freeing said pointers on error paths.

Signed-off-by: Milton Miller <miltonm@bga.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/include/asm/system.h
arch/powerpc/kernel/pci_dn.c
arch/powerpc/lib/alloc.c
arch/powerpc/platforms/cell/celleb_pci.c

index 5e474ddd227382350fc82ae0e2ca80352d1fd070..2dc595dda03baa9e63aad92e372e2e67a12e4725 100644 (file)
@@ -219,8 +219,6 @@ extern int mem_init_done;   /* set on boot once kmalloc can be called */
 extern int init_bootmem_done;  /* set once bootmem is available */
 extern phys_addr_t memory_limit;
 extern unsigned long klimit;
-
-extern void *alloc_maybe_bootmem(size_t size, gfp_t mask);
 extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask);
 
 extern int powersave_nap;      /* set if nap mode can be used in idle loop */
index d225d99fe39d8f076ee637377a43692024c39232..6baabc13306aa1940a98141914a86f9baa10b50a 100644 (file)
@@ -43,10 +43,9 @@ void * __devinit update_dn_pci_info(struct device_node *dn, void *data)
        const u32 *regs;
        struct pci_dn *pdn;
 
-       pdn = alloc_maybe_bootmem(sizeof(*pdn), GFP_KERNEL);
+       pdn = zalloc_maybe_bootmem(sizeof(*pdn), GFP_KERNEL);
        if (pdn == NULL)
                return NULL;
-       memset(pdn, 0, sizeof(*pdn));
        dn->data = pdn;
        pdn->node = dn;
        pdn->phb = phb;
index f53e09c7dac72d95af83ccdca072ccde135db6af..13b676c20d126396cf9db44dbbfd1a3238a7b84b 100644 (file)
@@ -6,14 +6,6 @@
 
 #include <asm/system.h>
 
-void * __init_refok alloc_maybe_bootmem(size_t size, gfp_t mask)
-{
-       if (mem_init_done)
-               return kmalloc(size, mask);
-       else
-               return alloc_bootmem(size);
-}
-
 void * __init_refok zalloc_maybe_bootmem(size_t size, gfp_t mask)
 {
        void *p;
index 2904b0a6b2c5db16001383ae5972a96c5504cfdc..5822141aa63f3f21f73739ea1b2210971698040b 100644 (file)
@@ -319,7 +319,7 @@ static int __init celleb_setup_fake_pci_device(struct device_node *node,
 
        size = 256;
        config = &private->fake_config[devno][fn];
-       *config = alloc_maybe_bootmem(size, GFP_KERNEL);
+       *config = zalloc_maybe_bootmem(size, GFP_KERNEL);
        if (*config == NULL) {
                printk(KERN_ERR "PCI: "
                       "not enough memory for fake configuration space\n");
@@ -330,7 +330,7 @@ static int __init celleb_setup_fake_pci_device(struct device_node *node,
 
        size = sizeof(struct celleb_pci_resource);
        res = &private->res[devno][fn];
-       *res = alloc_maybe_bootmem(size, GFP_KERNEL);
+       *res = zalloc_maybe_bootmem(size, GFP_KERNEL);
        if (*res == NULL) {
                printk(KERN_ERR
                       "PCI: not enough memory for resource data space\n");
@@ -431,7 +431,7 @@ static int __init phb_set_bus_ranges(struct device_node *dev,
 static void __init celleb_alloc_private_mem(struct pci_controller *hose)
 {
        hose->private_data =
-               alloc_maybe_bootmem(sizeof(struct celleb_pci_private),
+               zalloc_maybe_bootmem(sizeof(struct celleb_pci_private),
                        GFP_KERNEL);
 }