Merge pull request #188 from spartacus06/fix-list-corruption

fix list corruption in special section handlers
This commit is contained in:
Josh Poimboeuf 2014-05-15 15:44:10 -05:00
commit 59e9011a30
2 changed files with 19 additions and 3 deletions

View File

@ -1017,7 +1017,7 @@ void kpatch_regenerate_bug_table_rela_section(struct kpatch_elf *kelf)
}
/* overwrite with new relas list */
sec->relas = newrelas;
list_replace(&newrelas, &sec->relas);
/* include both rela and text sections */
sec->include = 1;
@ -1064,7 +1064,7 @@ void kpatch_regenerate_smp_locks_sections(struct kpatch_elf *kelf)
}
/* overwrite with new relas list */
sec->relas = newrelas;
list_replace(&newrelas, &sec->relas);
/* include both rela and text sections */
sec->include = 1;
@ -1129,7 +1129,7 @@ void kpatch_regenerate_parainstructions_sections(struct kpatch_elf *kelf)
}
/* overwrite with new relas table */
sec->relas = newrelas;
list_replace(&newrelas, &sec->relas);
/* mark sections for inclusion */
sec->include = 1;

View File

@ -142,6 +142,22 @@ static inline void list_del(struct list_head *entry)
entry->prev = LIST_POISON2;
}
/**
* list_replace - replace old entry by new one
* @old : the element to be replaced
* @new : the new element to insert
*
* If @old was empty, it will be overwritten.
*/
static inline void list_replace(struct list_head *old,
struct list_head *new)
{
new->next = old->next;
new->next->prev = new;
new->prev = old->prev;
new->prev->next = new;
}
#define list_entry(ptr, type, member) \
container_of(ptr, type, member)