mtd/drivers/mtd redboot.c,1.9,1.10
David Woodhouse
dwmw2 at infradead.org
Mon May 19 10:22:43 EDT 2003
Update of /home/cvs/mtd/drivers/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv17905/drivers/mtd
Modified Files:
redboot.c
Log Message:
Fix module leaving strings behind
Index: redboot.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/redboot.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- redboot.c 16 May 2003 17:08:24 -0000 1.9
+++ redboot.c 19 May 2003 14:22:41 -0000 1.10
@@ -45,7 +45,9 @@
int ret, i;
size_t retlen;
char *names;
+ char *nullname;
int namelen = 0;
+ static char nullstring[] = "unallocated";
buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
@@ -116,18 +118,24 @@
if (tmp_fl->img->flash_base + tmp_fl->img->size + master->erasesize < tmp_fl->next->img->flash_base)
nrparts++;
}
- parts = kmalloc(sizeof(*parts)*nrparts + namelen, GFP_KERNEL);
+ parts = kmalloc(sizeof(*parts)*nrparts + sizeof(nullstring) + namelen, GFP_KERNEL);
if (!parts) {
ret = -ENOMEM;
goto out;
}
- names = (char *)&parts[nrparts];
+
memset(parts, 0, sizeof(*parts)*nrparts + namelen);
+
+ /* FIXME: Include nullname only if it's used */
+ nullname = (char *)&parts[nrparts];
+ sprintf(nullname, nullstring);
+ names = nullname + sizeof(nullstring);
+
i=0;
if (fl->img->flash_base) {
- parts[0].name = "unallocated space";
+ parts[0].name = nullname;
parts[0].size = fl->img->flash_base;
parts[0].offset = 0;
}
@@ -143,7 +151,7 @@
i++;
parts[i].offset = parts[i-1].size + parts[i-1].offset;
parts[i].size = fl->next->img->flash_base - parts[i].offset;
- parts[i].name = "unallocated space";
+ parts[i].name = nullname;
}
tmp_fl = fl;
fl = fl->next;
More information about the linux-mtd-cvs
mailing list