Commit a891dbbe authored by Zheng Yejian's avatar Zheng Yejian Committed by Zheng Zengkai
Browse files

livepatch/core: Fix reference count issues

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4SFHQ



--------------------------------

Fix following reference count issues where get 'obj->mod' once but put
twice:
  1) klp_register_patch
      klp_init_patch
          klp_init_object
              klp_find_object_module
                  try_module_get    <-- 1. Get refcount once
              klp_init_object_loaded    <-- 2. If fail here!!!
              module_put    <-- 3. Put refcount first time
      klp_free_patch_start
          klp_free_objects
              __klp_free_objects
                  module_put    <-- 4. 'obj->mod' not null, put twice!!!

  2) klp_register_patch
    klp_init_patch
        klp_init_object
            klp_find_object_module
                try_module_get    <-- 1. Get refcount once
        kobject_add    <-- 2. If other objs fail here!!!
        klp_free_objects_mod_limited
            module_put    <-- 3. Put refcount first time
    klp_free_patch_start
        klp_free_objects
            __klp_free_objects
                module_put    <-- 4. 'obj->mod' not null, put twice!!!

Fixes: c33e4283 ("livepatch/core: Allow implementation without ftrace")
Signed-off-by: default avatarZheng Yejian <zhengyejian1@huawei.com>
Reviewed-by: default avatarXu Kuohai <xukuohai@huawei.com>
Reviewed-by: default avatarCheng Jian <cj.chengjian@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent df092ea4
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment