Commit ff6da9ca authored by Russell King's avatar Russell King

[ARM] Fix potential oops in epxa10db-flash.c

Fix potential oops if kmalloc returns NULL.
Really return an error when out of memory.
parent 79203d1a
...@@ -199,12 +199,12 @@ static int __init epxa_default_partitions(struct mtd_info *master, struct mtd_pa ...@@ -199,12 +199,12 @@ static int __init epxa_default_partitions(struct mtd_info *master, struct mtd_pa
printk("Using default partitions for %s\n",BOARD_NAME); printk("Using default partitions for %s\n",BOARD_NAME);
npartitions=1; npartitions=1;
parts = kmalloc(npartitions*sizeof(*parts)+strlen(name), GFP_KERNEL); parts = kmalloc(npartitions*sizeof(*parts)+strlen(name)+1, GFP_KERNEL);
memzero(parts,npartitions*sizeof(*parts)+strlen(name));
if (!parts) { if (!parts) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
memzero(parts,npartitions*sizeof(*parts)+strlen(name));
i=0; i=0;
names = (char *)&parts[npartitions]; names = (char *)&parts[npartitions];
parts[i].name = names; parts[i].name = names;
...@@ -218,10 +218,11 @@ static int __init epxa_default_partitions(struct mtd_info *master, struct mtd_pa ...@@ -218,10 +218,11 @@ static int __init epxa_default_partitions(struct mtd_info *master, struct mtd_pa
parts[i].size = FLASH_SIZE-0x00180000; parts[i].size = FLASH_SIZE-0x00180000;
parts[i].offset = 0x00180000; parts[i].offset = 0x00180000;
#endif #endif
ret = npartitions;
out: out:
*pparts = parts; *pparts = parts;
return npartitions; return ret;
} }
......
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