2019-09-05 15:50:11

by Miroslav Benes

[permalink] [raw]
Subject: [RFC PATCH v2 3/3] livepatch: Clean up klp_update_object_relocations() return paths

Signed-off-by: Miroslav Benes <[email protected]>
---
kernel/livepatch/core.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 023c9333c276..73ddddd5add5 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -251,7 +251,7 @@ static int klp_update_object_relocations(struct module *pmod,
struct klp_object *obj,
reloc_update_fn_t reloc_update_fn)
{
- int i, cnt, ret = 0;
+ int i, cnt, ret;
const char *objname, *secname;
char sec_objname[MODULE_NAME_LEN];
Elf_Shdr *sec;
@@ -277,8 +277,7 @@ static int klp_update_object_relocations(struct module *pmod,
if (cnt != 1) {
pr_err("section %s has an incorrectly formatted name\n",
secname);
- ret = -EINVAL;
- break;
+ return -EINVAL;
}

if (strcmp(objname, sec_objname))
@@ -286,10 +285,10 @@ static int klp_update_object_relocations(struct module *pmod,

ret = reloc_update_fn(pmod, i);
if (ret)
- break;
+ return ret;
}

- return ret;
+ return 0;
}

/*
--
2.23.0


2019-10-02 13:48:32

by Petr Mladek

[permalink] [raw]
Subject: Re: [RFC PATCH v2 3/3] livepatch: Clean up klp_update_object_relocations() return paths

On Thu 2019-09-05 14:45:14, Miroslav Benes wrote:
> Signed-off-by: Miroslav Benes <[email protected]>

This might depend on personal preferences. What was the motivation
for this patch, please? Did it just follow some common
style in this source file?

To make it clear. I have no real preference. I just want to avoid
some back and forth changes of the code depending on who touches
it at the moment.

I would prefer to either remove this patch or explain the motivation
in the commit message. Beside that

Reviewed-by: Petr Mladek <[email protected]>

Best Regards,
Petr

2019-10-03 09:09:51

by Miroslav Benes

[permalink] [raw]
Subject: Re: [RFC PATCH v2 3/3] livepatch: Clean up klp_update_object_relocations() return paths

On Wed, 2 Oct 2019, Petr Mladek wrote:

> On Thu 2019-09-05 14:45:14, Miroslav Benes wrote:
> > Signed-off-by: Miroslav Benes <[email protected]>
>
> This might depend on personal preferences.

True.

> What was the motivation
> for this patch, please? Did it just follow some common
> style in this source file?

We had it like this once, so it is only going back to the original code.
And yes, I think it is better.

Commit b56b36ee6751 ("livepatch: Cleanup module page permission changes")
changed it due to the error handling. Commit 255e732c61db ("livepatch: use
arch_klp_init_object_loaded() to finish arch-specific tasks") removed the
reason for the change but did not cleanup the rest.

> To make it clear. I have no real preference. I just want to avoid
> some back and forth changes of the code depending on who touches
> it at the moment.

I have no real preference either. I noticed something I did not like while
touching the code and that's it.

> I would prefer to either remove this patch or explain the motivation
> in the commit message. Beside that
>
> Reviewed-by: Petr Mladek <[email protected]>

Ok, thanks.
Miroslav