Skip to content

Commit

Permalink
powerpc: Remove alloc_maybe_bootmem for zalloc version
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Milton Miller authored and Benjamin Herrenschmidt committed May 19, 2011
1 parent 7ca8aa0 commit a56555e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 15 deletions.
2 changes: 0 additions & 2 deletions arch/powerpc/include/asm/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 1 addition & 2 deletions arch/powerpc/kernel/pci_dn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 0 additions & 8 deletions arch/powerpc/lib/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions arch/powerpc/platforms/cell/celleb_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit a56555e

Please sign in to comment.