Commit a56555e5 authored by Milton Miller's avatar Milton Miller Committed by Benjamin Herrenschmidt

powerpc: Remove alloc_maybe_bootmem for zalloc version

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: default avatarMilton Miller <miltonm@bga.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 7ca8aa09
...@@ -219,8 +219,6 @@ extern int mem_init_done; /* set on boot once kmalloc can be called */ ...@@ -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 int init_bootmem_done; /* set once bootmem is available */
extern phys_addr_t memory_limit; extern phys_addr_t memory_limit;
extern unsigned long klimit; 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 void *zalloc_maybe_bootmem(size_t size, gfp_t mask);
extern int powersave_nap; /* set if nap mode can be used in idle loop */ extern int powersave_nap; /* set if nap mode can be used in idle loop */
......
...@@ -43,10 +43,9 @@ void * __devinit update_dn_pci_info(struct device_node *dn, void *data) ...@@ -43,10 +43,9 @@ void * __devinit update_dn_pci_info(struct device_node *dn, void *data)
const u32 *regs; const u32 *regs;
struct pci_dn *pdn; struct pci_dn *pdn;
pdn = alloc_maybe_bootmem(sizeof(*pdn), GFP_KERNEL); pdn = zalloc_maybe_bootmem(sizeof(*pdn), GFP_KERNEL);
if (pdn == NULL) if (pdn == NULL)
return NULL; return NULL;
memset(pdn, 0, sizeof(*pdn));
dn->data = pdn; dn->data = pdn;
pdn->node = dn; pdn->node = dn;
pdn->phb = phb; pdn->phb = phb;
......
...@@ -6,14 +6,6 @@ ...@@ -6,14 +6,6 @@
#include <asm/system.h> #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 * __init_refok zalloc_maybe_bootmem(size_t size, gfp_t mask)
{ {
void *p; void *p;
......
...@@ -319,7 +319,7 @@ static int __init celleb_setup_fake_pci_device(struct device_node *node, ...@@ -319,7 +319,7 @@ static int __init celleb_setup_fake_pci_device(struct device_node *node,
size = 256; size = 256;
config = &private->fake_config[devno][fn]; config = &private->fake_config[devno][fn];
*config = alloc_maybe_bootmem(size, GFP_KERNEL); *config = zalloc_maybe_bootmem(size, GFP_KERNEL);
if (*config == NULL) { if (*config == NULL) {
printk(KERN_ERR "PCI: " printk(KERN_ERR "PCI: "
"not enough memory for fake configuration space\n"); "not enough memory for fake configuration space\n");
...@@ -330,7 +330,7 @@ static int __init celleb_setup_fake_pci_device(struct device_node *node, ...@@ -330,7 +330,7 @@ static int __init celleb_setup_fake_pci_device(struct device_node *node,
size = sizeof(struct celleb_pci_resource); size = sizeof(struct celleb_pci_resource);
res = &private->res[devno][fn]; res = &private->res[devno][fn];
*res = alloc_maybe_bootmem(size, GFP_KERNEL); *res = zalloc_maybe_bootmem(size, GFP_KERNEL);
if (*res == NULL) { if (*res == NULL) {
printk(KERN_ERR printk(KERN_ERR
"PCI: not enough memory for resource data space\n"); "PCI: not enough memory for resource data space\n");
...@@ -431,7 +431,7 @@ static int __init phb_set_bus_ranges(struct device_node *dev, ...@@ -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) static void __init celleb_alloc_private_mem(struct pci_controller *hose)
{ {
hose->private_data = hose->private_data =
alloc_maybe_bootmem(sizeof(struct celleb_pci_private), zalloc_maybe_bootmem(sizeof(struct celleb_pci_private),
GFP_KERNEL); GFP_KERNEL);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment