mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-06 05:13:18 +00:00
livepatch: Call klp_match_callback() in klp_find_callback() to avoid code duplication
The implementation of function klp_match_callback() is identical to the partial implementation of function klp_find_callback(). So call function klp_match_callback() in function klp_find_callback() instead of the duplicated code. Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> Acked-by: Song Liu <song@kernel.org> Reviewed-by: Petr Mladek <pmladek@suse.com> Suggested-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
This commit is contained in:
parent
169a58ad82
commit
4f1354d5c6
@ -125,34 +125,6 @@ struct klp_find_arg {
|
||||
unsigned long pos;
|
||||
};
|
||||
|
||||
static int klp_find_callback(void *data, const char *name,
|
||||
struct module *mod, unsigned long addr)
|
||||
{
|
||||
struct klp_find_arg *args = data;
|
||||
|
||||
if ((mod && !args->objname) || (!mod && args->objname))
|
||||
return 0;
|
||||
|
||||
if (strcmp(args->name, name))
|
||||
return 0;
|
||||
|
||||
if (args->objname && strcmp(args->objname, mod->name))
|
||||
return 0;
|
||||
|
||||
args->addr = addr;
|
||||
args->count++;
|
||||
|
||||
/*
|
||||
* Finish the search when the symbol is found for the desired position
|
||||
* or the position is not defined for a non-unique symbol.
|
||||
*/
|
||||
if ((args->pos && (args->count == args->pos)) ||
|
||||
(!args->pos && (args->count > 1)))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int klp_match_callback(void *data, unsigned long addr)
|
||||
{
|
||||
struct klp_find_arg *args = data;
|
||||
@ -171,6 +143,23 @@ static int klp_match_callback(void *data, unsigned long addr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int klp_find_callback(void *data, const char *name,
|
||||
struct module *mod, unsigned long addr)
|
||||
{
|
||||
struct klp_find_arg *args = data;
|
||||
|
||||
if ((mod && !args->objname) || (!mod && args->objname))
|
||||
return 0;
|
||||
|
||||
if (strcmp(args->name, name))
|
||||
return 0;
|
||||
|
||||
if (args->objname && strcmp(args->objname, mod->name))
|
||||
return 0;
|
||||
|
||||
return klp_match_callback(data, addr);
|
||||
}
|
||||
|
||||
static int klp_find_object_symbol(const char *objname, const char *name,
|
||||
unsigned long sympos, unsigned long *addr)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user