From a7ecd69401fbac22dcab75988e65a54cd0f301d4 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Mon, 1 Oct 2018 12:01:43 +0300 Subject: [PATCH] got_patcher: use new dentry manipulation interface Change-Id: I7dbc355c8ef6c3e82582118c015ecfcb3f128a9a Signed-off-by: Vyacheslav Cherkashin --- modules/got_patcher/gt_module.c | 65 +++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/modules/got_patcher/gt_module.c b/modules/got_patcher/gt_module.c index 3d9b2e6..32e48c1 100644 --- a/modules/got_patcher/gt_module.c +++ b/modules/got_patcher/gt_module.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include "gt.h" @@ -485,7 +485,7 @@ static void _destroy_linker_probe_el_no_lock(struct l_probe_el *l_probe) put_pf_group(l_probe->pfg); if (l_probe->task_id == GT_SET_BY_DENTRY && l_probe->dentry != NULL) - swap_put_dentry(l_probe->dentry); + swap_dput(l_probe->dentry); if (l_probe->task_id == GT_SET_BY_ID && l_probe->id != NULL) kfree(l_probe->id); @@ -665,21 +665,17 @@ int gtm_set_linker_path(char *path) { struct dentry *dentry; - dentry = swap_get_dentry(path); + dentry = swap_dget_by_path(path); if (dentry == NULL) return -EINVAL; - /* We use get_dentry only once, so use put dentry also only once */ - if (_linker_fixup.dentry != NULL || - _linker_reloc.dentry != NULL) { - if (_linker_fixup.dentry != NULL) - swap_put_dentry(_linker_fixup.dentry); - else - swap_put_dentry(_linker_reloc.dentry); - } - + /* update fixup dentry */ + swap_dput(_linker_fixup.dentry); _linker_fixup.dentry = dentry; - _linker_reloc.dentry = dentry; + + /* update reloc dentry */ + swap_dput(_linker_reloc.dentry); + _linker_reloc.dentry = swap_dget(dentry); return 0; } @@ -728,7 +724,7 @@ int gtm_add_by_path(char *path) struct l_probe_el *l_probe; int ret; - dentry = swap_get_dentry(path); + dentry = swap_dget_by_path(path); if (dentry == NULL) return -EINVAL; @@ -761,7 +757,7 @@ add_by_path_put_pfg: put_pf_group(pfg); add_by_path_put_dentry: - swap_put_dentry(dentry); + swap_dput(dentry); return ret; } @@ -855,7 +851,7 @@ int gtm_del_by_path(char *path) struct dentry *dentry; int ret = 0; - dentry = swap_get_dentry(path); + dentry = swap_dget_by_path(path); if (dentry == NULL) return -EINVAL; @@ -939,19 +935,17 @@ int gtm_set_handler_path(char *path) struct dentry *dentry; int ret; - /* We use get_dentry only once, so use put dentry also only once */ - dentry = swap_get_dentry(path); + dentry = swap_dget_by_path(path); if (dentry == NULL) return -EINVAL; - if (_handler_fixup.dentry) - swap_put_dentry(_handler_fixup.dentry); - - if (_handler_reloc.dentry) - swap_put_dentry(_handler_reloc.dentry); - + /* update fixup dentry */ + swap_dput(_handler_fixup.dentry); _handler_fixup.dentry = dentry; - _handler_reloc.dentry = dentry; + + /* update reloc dentry */ + swap_dput(_handler_reloc.dentry); + _handler_reloc.dentry = swap_dget(dentry); /* TODO Do smth with this: * make interface for loader to remove handlers @@ -980,13 +974,11 @@ int gtm_set_pthread_path(char *path) { struct dentry *dentry; - dentry = swap_get_dentry(path); + dentry = swap_dget_by_path(path); if (dentry == NULL) return -EINVAL; - if (_pthread_init.dentry != NULL) - swap_put_dentry(_pthread_init.dentry); - + swap_dput(_pthread_init.dentry); _pthread_init.dentry = dentry; return 0; @@ -1027,16 +1019,11 @@ static void gtm_exit(void) _clean_linker_probes(); - /* We use get_dentry only once, so use put dentry also only once */ - if (_handler_fixup.dentry != NULL || - _handler_reloc.dentry != NULL) { - if (_handler_fixup.dentry != NULL) - swap_put_dentry(_handler_fixup.dentry); - else - swap_put_dentry(_handler_reloc.dentry); - _handler_reloc.dentry = NULL; - _handler_fixup.dentry = NULL; - } + swap_dput(_handler_fixup.dentry); + _handler_fixup.dentry = NULL; + + swap_dput(_handler_reloc.dentry); + _handler_reloc.dentry = NULL; } SWAP_LIGHT_INIT_MODULE(NULL, gtm_init, gtm_exit, NULL, NULL); -- 2.7.4