Skip to content

Commit 5074c7f

Browse files
author
Al Viro
committed
[elf-fdpic] coredump: don't bother with cyclic list for per-thread objects
plain single-linked list is just fine here... Signed-off-by: Al Viro <[email protected]>
1 parent 7a89602 commit 5074c7f

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

fs/binfmt_elf_fdpic.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
14531453
/* Here is the structure in which status of each thread is captured. */
14541454
struct elf_thread_status
14551455
{
1456-
struct list_head list;
1456+
struct elf_thread_status *next;
14571457
struct elf_prstatus_fdpic prstatus; /* NT_PRSTATUS */
14581458
elf_fpregset_t fpu; /* NT_PRFPREG */
14591459
struct task_struct *thread;
@@ -1578,8 +1578,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
15781578
struct memelfnote *notes = NULL;
15791579
struct elf_prstatus_fdpic *prstatus = NULL; /* NT_PRSTATUS */
15801580
struct elf_prpsinfo *psinfo = NULL; /* NT_PRPSINFO */
1581-
LIST_HEAD(thread_list);
1582-
struct list_head *t;
1581+
struct elf_thread_status *thread_list = NULL;
15831582
elf_fpregset_t *fpu = NULL;
15841583
int thread_status_size = 0;
15851584
elf_addr_t *auxv;
@@ -1627,15 +1626,12 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
16271626
goto end_coredump;
16281627

16291628
tmp->thread = ct->task;
1630-
list_add(&tmp->list, &thread_list);
1629+
tmp->next = thread_list;
1630+
thread_list = tmp;
16311631
}
16321632

1633-
list_for_each(t, &thread_list) {
1634-
struct elf_thread_status *tmp;
1635-
int sz;
1636-
1637-
tmp = list_entry(t, struct elf_thread_status, list);
1638-
sz = elf_dump_thread_status(cprm->siginfo->si_signo, tmp);
1633+
for (tmp = thread_list; tmp; tmp = tmp->next) {
1634+
int sz = elf_dump_thread_status(cprm->siginfo->si_signo, tmp);
16391635
thread_status_size += sz;
16401636
}
16411637

@@ -1760,10 +1756,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
17601756
goto end_coredump;
17611757

17621758
/* write out the thread status notes section */
1763-
list_for_each(t, &thread_list) {
1764-
struct elf_thread_status *tmp =
1765-
list_entry(t, struct elf_thread_status, list);
1766-
1759+
for (tmp = thread_list; tmp; tmp = tmp->next) {
17671760
for (i = 0; i < tmp->num_notes; i++)
17681761
if (!writenote(&tmp->notes[i], cprm))
17691762
goto end_coredump;
@@ -1791,10 +1784,10 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
17911784
}
17921785

17931786
end_coredump:
1794-
while (!list_empty(&thread_list)) {
1795-
struct list_head *tmp = thread_list.next;
1796-
list_del(tmp);
1797-
kfree(list_entry(tmp, struct elf_thread_status, list));
1787+
while (thread_list) {
1788+
tmp = thread_list;
1789+
thread_list = thread_list->next;
1790+
kfree(tmp);
17981791
}
17991792
kfree(phdr4note);
18001793
kfree(elf);

0 commit comments

Comments
 (0)