[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210121074959.313333-4-hch@lst.de>
Date: Thu, 21 Jan 2021 08:49:49 +0100
From: Christoph Hellwig <hch@....de>
To: Frederic Barrat <fbarrat@...ux.ibm.com>,
Andrew Donnellan <ajd@...ux.ibm.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>, Jessica Yu <jeyu@...nel.org>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Jiri Kosina <jikos@...nel.org>,
Miroslav Benes <mbenes@...e.cz>,
Petr Mladek <pmladek@...e.com>,
Joe Lawrence <joe.lawrence@...hat.com>
Cc: Masahiro Yamada <masahiroy@...nel.org>,
Michal Marek <michal.lkml@...kovi.net>,
linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
dri-devel@...ts.freedesktop.org, live-patching@...r.kernel.org,
linux-kbuild@...r.kernel.org
Subject: [PATCH 03/13] livepatch: refactor klp_init_object
Merge three calls to klp_is_module (including one hidden inside
klp_find_object_module) into a single one to simplify the code a bit.
Signed-off-by: Christoph Hellwig <hch@....de>
---
kernel/livepatch/core.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index f76fdb9255323d..a7f625dc24add3 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -54,9 +54,6 @@ static void klp_find_object_module(struct klp_object *obj)
{
struct module *mod;
- if (!klp_is_module(obj))
- return;
-
mutex_lock(&module_mutex);
/*
* We do not want to block removal of patched modules and therefore
@@ -73,7 +70,6 @@ static void klp_find_object_module(struct klp_object *obj)
*/
if (mod && mod->klp_alive)
obj->mod = mod;
-
mutex_unlock(&module_mutex);
}
@@ -823,15 +819,19 @@ static int klp_init_object(struct klp_patch *patch, struct klp_object *obj)
int ret;
const char *name;
- if (klp_is_module(obj) && strlen(obj->name) >= MODULE_NAME_LEN)
- return -EINVAL;
-
obj->patched = false;
obj->mod = NULL;
- klp_find_object_module(obj);
+ if (klp_is_module(obj)) {
+ if (strlen(obj->name) >= MODULE_NAME_LEN)
+ return -EINVAL;
+ name = obj->name;
+
+ klp_find_object_module(obj);
+ } else {
+ name = "vmlinux";
+ }
- name = klp_is_module(obj) ? obj->name : "vmlinux";
ret = kobject_add(&obj->kobj, &patch->kobj, "%s", name);
if (ret)
return ret;
--
2.29.2
Powered by blists - more mailing lists