[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <alpine.LSU.2.21.1811222132050.19197@pobox.suse.cz>
Date: Fri, 23 Nov 2018 13:00:35 +0100 (CET)
From: Miroslav Benes <mbenes@...e.cz>
To: Petr Mladek <pmladek@...e.com>
cc: Jiri Kosina <jikos@...nel.org>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Jason Baron <jbaron@...mai.com>,
Joe Lawrence <joe.lawrence@...hat.com>,
Evgenii Shatokhin <eshatokhin@...tuozzo.com>,
live-patching@...r.kernel.org, linux-kernel@...r.kernel.org,
Jessica Yu <jeyu@...nel.org>
Subject: Re: [PATCH v13 08/12] livepatch: Add atomic replace
On Mon, 15 Oct 2018, Petr Mladek wrote:
> +static int klp_add_object_nops(struct klp_patch *patch,
> + struct klp_object *old_obj)
> +{
> + struct klp_object *obj;
> + struct klp_func *func, *old_func;
> +
> + obj = klp_find_object(patch, old_obj);
> +
> + if (!obj) {
> + obj = klp_alloc_object_dynamic(old_obj->name);
> + if (!obj)
> + return -ENOMEM;
> +
> + list_add(&obj->node, &patch->obj_list);
> + }
> +
> + klp_for_each_func(old_obj, old_func) {
> + func = klp_find_func(obj, old_func);
> + if (func)
> + continue;
> +
> + func = klp_alloc_func_nop(old_func, obj);
> + if (!func)
> + return -ENOMEM;
> +
> + list_add(&func->node, &obj->func_list);
> + }
> +
> + return 0;
> +}
Maybe you should consider list_add_tail() here too.
> +
> +/*
> + * Add 'nop' functions which simply return to the caller to run
> + * the original function. The 'nop' functions are added to a
> + * patch to facilitate a 'replace' mode.
> + */
> +static int klp_add_nops(struct klp_patch *patch)
> +{
> + struct klp_patch *old_patch;
> + struct klp_object *old_obj;
> + int err = 0;
The initialization is unnecessary.
> + list_for_each_entry(old_patch, &klp_patches, list) {
> + klp_for_each_object(old_patch, old_obj) {
> + err = klp_add_object_nops(patch, old_obj);
> + if (err)
> + return err;
> + }
> + }
> +
> + return 0;
> +}
Miroslav
Powered by blists - more mailing lists