aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorMilton Miller <miltonm@bga.com>2011-05-10 15:29:24 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2011-05-19 01:30:57 -0400
commita56555e573d3740d588d912aada506d57759cf5d (patch)
tree1f1c44ec8f60cc68f6fd79e3c6c54db2aee02c4c /arch/powerpc
parent7ca8aa0924712de81485c70e00bbea8c092a08c1 (diff)
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: Milton Miller <miltonm@bga.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/include/asm/system.h2
-rw-r--r--arch/powerpc/kernel/pci_dn.c3
-rw-r--r--arch/powerpc/lib/alloc.c8
-rw-r--r--arch/powerpc/platforms/cell/celleb_pci.c6
4 files changed, 4 insertions, 15 deletions
diff --git a/arch/powerpc/include/asm/system.h b/arch/powerpc/include/asm/system.h
index 5e474ddd2273..2dc595dda03b 100644
--- a/arch/powerpc/include/asm/system.h
+++ b/arch/powerpc/include/asm/system.h
@@ -219,8 +219,6 @@ extern int mem_init_done; /* set on boot once kmalloc can be called */
219extern int init_bootmem_done; /* set once bootmem is available */ 219extern int init_bootmem_done; /* set once bootmem is available */
220extern phys_addr_t memory_limit; 220extern phys_addr_t memory_limit;
221extern unsigned long klimit; 221extern unsigned long klimit;
222
223extern void *alloc_maybe_bootmem(size_t size, gfp_t mask);
224extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask); 222extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask);
225 223
226extern int powersave_nap; /* set if nap mode can be used in idle loop */ 224extern int powersave_nap; /* set if nap mode can be used in idle loop */
diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c
index d225d99fe39d..6baabc13306a 100644
--- a/arch/powerpc/kernel/pci_dn.c
+++ b/arch/powerpc/kernel/pci_dn.c
@@ -43,10 +43,9 @@ void * __devinit update_dn_pci_info(struct device_node *dn, void *data)
43 const u32 *regs; 43 const u32 *regs;
44 struct pci_dn *pdn; 44 struct pci_dn *pdn;
45 45
46 pdn = alloc_maybe_bootmem(sizeof(*pdn), GFP_KERNEL); 46 pdn = zalloc_maybe_bootmem(sizeof(*pdn), GFP_KERNEL);
47 if (pdn == NULL) 47 if (pdn == NULL)
48 return NULL; 48 return NULL;
49 memset(pdn, 0, sizeof(*pdn));
50 dn->data = pdn; 49 dn->data = pdn;
51 pdn->node = dn; 50 pdn->node = dn;
52 pdn->phb = phb; 51 pdn->phb = phb;
diff --git a/arch/powerpc/lib/alloc.c b/arch/powerpc/lib/alloc.c
index f53e09c7dac7..13b676c20d12 100644
--- a/arch/powerpc/lib/alloc.c
+++ b/arch/powerpc/lib/alloc.c
@@ -6,14 +6,6 @@
6 6
7#include <asm/system.h> 7#include <asm/system.h>
8 8
9void * __init_refok alloc_maybe_bootmem(size_t size, gfp_t mask)
10{
11 if (mem_init_done)
12 return kmalloc(size, mask);
13 else
14 return alloc_bootmem(size);
15}
16
17void * __init_refok zalloc_maybe_bootmem(size_t size, gfp_t mask) 9void * __init_refok zalloc_maybe_bootmem(size_t size, gfp_t mask)
18{ 10{
19 void *p; 11 void *p;
diff --git a/arch/powerpc/platforms/cell/celleb_pci.c b/arch/powerpc/platforms/cell/celleb_pci.c
index 2904b0a6b2c5..5822141aa63f 100644
--- a/arch/powerpc/platforms/cell/celleb_pci.c
+++ b/arch/powerpc/platforms/cell/celleb_pci.c
@@ -319,7 +319,7 @@ static int __init celleb_setup_fake_pci_device(struct device_node *node,
319 319
320 size = 256; 320 size = 256;
321 config = &private->fake_config[devno][fn]; 321 config = &private->fake_config[devno][fn];
322 *config = alloc_maybe_bootmem(size, GFP_KERNEL); 322 *config = zalloc_maybe_bootmem(size, GFP_KERNEL);
323 if (*config == NULL) { 323 if (*config == NULL) {
324 printk(KERN_ERR "PCI: " 324 printk(KERN_ERR "PCI: "
325 "not enough memory for fake configuration space\n"); 325 "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 330
331 size = sizeof(struct celleb_pci_resource); 331 size = sizeof(struct celleb_pci_resource);
332 res = &private->res[devno][fn]; 332 res = &private->res[devno][fn];
333 *res = alloc_maybe_bootmem(size, GFP_KERNEL); 333 *res = zalloc_maybe_bootmem(size, GFP_KERNEL);
334 if (*res == NULL) { 334 if (*res == NULL) {
335 printk(KERN_ERR 335 printk(KERN_ERR
336 "PCI: not enough memory for resource data space\n"); 336 "PCI: not enough memory for resource data space\n");
@@ -431,7 +431,7 @@ static int __init phb_set_bus_ranges(struct device_node *dev,
431static void __init celleb_alloc_private_mem(struct pci_controller *hose) 431static void __init celleb_alloc_private_mem(struct pci_controller *hose)
432{ 432{
433 hose->private_data = 433 hose->private_data =
434 alloc_maybe_bootmem(sizeof(struct celleb_pci_private), 434 zalloc_maybe_bootmem(sizeof(struct celleb_pci_private),
435 GFP_KERNEL); 435 GFP_KERNEL);
436} 436}
437 437