Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
[powerpc.git] / fs / proc / kcore.c
index 6a984f6..1294eda 100644 (file)
@@ -100,7 +100,7 @@ static int notesize(struct memelfnote *en)
        int sz;
 
        sz = sizeof(struct elf_note);
-       sz += roundup(strlen(en->name), 4);
+       sz += roundup((strlen(en->name) + 1), 4);
        sz += roundup(en->datasz, 4);
 
        return sz;
@@ -116,7 +116,7 @@ static char *storenote(struct memelfnote *men, char *bufp)
 
 #define DUMP_WRITE(addr,nr) do { memcpy(bufp,addr,nr); bufp += nr; } while(0)
 
-       en.n_namesz = strlen(men->name);
+       en.n_namesz = strlen(men->name) + 1;
        en.n_descsz = men->datasz;
        en.n_type = men->type;
 
@@ -279,12 +279,11 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
                tsz = elf_buflen - *fpos;
                if (buflen < tsz)
                        tsz = buflen;
-               elf_buf = kmalloc(elf_buflen, GFP_ATOMIC);
+               elf_buf = kzalloc(elf_buflen, GFP_ATOMIC);
                if (!elf_buf) {
                        read_unlock(&kclist_lock);
                        return -ENOMEM;
                }
-               memset(elf_buf, 0, elf_buflen);
                elf_kcore_store_hdr(elf_buf, nphdr, elf_buflen);
                read_unlock(&kclist_lock);
                if (copy_to_user(buffer, elf_buf + *fpos, tsz)) {
@@ -330,10 +329,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
                        unsigned long curstart = start;
                        unsigned long cursize = tsz;
 
-                       elf_buf = kmalloc(tsz, GFP_KERNEL);
+                       elf_buf = kzalloc(tsz, GFP_KERNEL);
                        if (!elf_buf)
                                return -ENOMEM;
-                       memset(elf_buf, 0, tsz);
 
                        read_lock(&vmlist_lock);
                        for (m=vmlist; m && cursize; m=m->next) {