lkml.org 
[lkml]   [2018]   [Nov]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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

\
 
 \ /
  Last update: 2018-11-23 13:01    [W:0.180 / U:0.792 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site