diff options
author | Jason Baron <jbaron@akamai.com> | 2019-01-09 07:43:24 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2019-01-11 14:51:24 -0500 |
commit | 20e55025958e18e671d92c7adea00c301ac93c43 (patch) | |
tree | 3c2a116fee563aa31fd637a34d28fb6254885568 /kernel/livepatch/core.c | |
parent | 958ef1e39d24d6cb8bf2a7406130a98c9564230f (diff) |
livepatch: Use lists to manage patches, objects and functions
Currently klp_patch contains a pointer to a statically allocated array of
struct klp_object and struct klp_objects contains a pointer to a statically
allocated array of klp_func. In order to allow for the dynamic allocation
of objects and functions, link klp_patch, klp_object, and klp_func together
via linked lists. This allows us to more easily allocate new objects and
functions, while having the iterator be a simple linked list walk.
The static structures are added to the lists early. It allows to add
the dynamically allocated objects before klp_init_object() and
klp_init_func() calls. Therefore it reduces the further changes
to the code.
This patch does not change the existing behavior.
Signed-off-by: Jason Baron <jbaron@akamai.com>
[pmladek@suse.com: Initialize lists before init calls]
Signed-off-by: Petr Mladek <pmladek@suse.com>
Acked-by: Miroslav Benes <mbenes@suse.cz>
Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Jiri Kosina <jikos@kernel.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'kernel/livepatch/core.c')
-rw-r--r-- | kernel/livepatch/core.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index bd41b03a72d5..37d0d3645fa6 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c | |||
@@ -659,20 +659,25 @@ static int klp_init_patch_early(struct klp_patch *patch) | |||
659 | return -EINVAL; | 659 | return -EINVAL; |
660 | 660 | ||
661 | INIT_LIST_HEAD(&patch->list); | 661 | INIT_LIST_HEAD(&patch->list); |
662 | INIT_LIST_HEAD(&patch->obj_list); | ||
662 | patch->kobj_added = false; | 663 | patch->kobj_added = false; |
663 | patch->enabled = false; | 664 | patch->enabled = false; |
664 | patch->forced = false; | 665 | patch->forced = false; |
665 | INIT_WORK(&patch->free_work, klp_free_patch_work_fn); | 666 | INIT_WORK(&patch->free_work, klp_free_patch_work_fn); |
666 | init_completion(&patch->finish); | 667 | init_completion(&patch->finish); |
667 | 668 | ||
668 | klp_for_each_object(patch, obj) { | 669 | klp_for_each_object_static(patch, obj) { |
669 | if (!obj->funcs) | 670 | if (!obj->funcs) |
670 | return -EINVAL; | 671 | return -EINVAL; |
671 | 672 | ||
673 | INIT_LIST_HEAD(&obj->func_list); | ||
672 | obj->kobj_added = false; | 674 | obj->kobj_added = false; |
675 | list_add_tail(&obj->node, &patch->obj_list); | ||
673 | 676 | ||
674 | klp_for_each_func(obj, func) | 677 | klp_for_each_func_static(obj, func) { |
675 | func->kobj_added = false; | 678 | func->kobj_added = false; |
679 | list_add_tail(&func->node, &obj->func_list); | ||
680 | } | ||
676 | } | 681 | } |
677 | 682 | ||
678 | if (!try_module_get(patch->mod)) | 683 | if (!try_module_get(patch->mod)) |