diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index 0cf8a24cf6c300a6f1b59c6931e6a71f166aef68..f9327e51ce997024d8c5aa8aafba8db78a8347ae 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c @@ -20,6 +20,7 @@ #include #include #include +#include #define CORE_STR "CORE" @@ -57,7 +58,7 @@ struct memelfnote void *data; }; -static struct kcore_list *kclist; +static LIST_HEAD(kclist_head); static DEFINE_RWLOCK(kclist_lock); void @@ -67,8 +68,7 @@ kclist_add(struct kcore_list *new, void *addr, size_t size) new->size = size; write_lock(&kclist_lock); - new->next = kclist; - kclist = new; + list_add_tail(&new->list, &kclist_head); write_unlock(&kclist_lock); } @@ -80,7 +80,7 @@ static size_t get_kcore_size(int *nphdr, size_t *elf_buflen) *nphdr = 1; /* PT_NOTE */ size = 0; - for (m=kclist; m; m=m->next) { + list_for_each_entry(m, &kclist_head, list) { try = kc_vaddr_to_offset((size_t)m->addr + m->size); if (try > size) size = try; @@ -192,7 +192,7 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff) nhdr->p_align = 0; /* setup ELF PT_LOAD program header for every area */ - for (m=kclist; m; m=m->next) { + list_for_each_entry(m, &kclist_head, list) { phdr = (struct elf_phdr *) bufp; bufp += sizeof(struct elf_phdr); offset += sizeof(struct elf_phdr); @@ -317,7 +317,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) struct kcore_list *m; read_lock(&kclist_lock); - for (m=kclist; m; m=m->next) { + list_for_each_entry(m, &kclist_head, list) { if (start >= m->addr && start < (m->addr+m->size)) break; } diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index e6e77d31c41882c25111204f90114a127f57e4f6..0aff2a62eba933664e4491c3843230e6ec2b6387 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h @@ -79,7 +79,7 @@ struct proc_dir_entry { }; struct kcore_list { - struct kcore_list *next; + struct list_head list; unsigned long addr; size_t size; };