got_patcher: fix 'dentry' leaks 34/191034/4
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Tue, 9 Oct 2018 15:37:33 +0000 (18:37 +0300)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Fri, 12 Oct 2018 12:48:21 +0000 (15:48 +0300)
Change-Id: I5f9ea49223387cc557b237e61135fc00e55ebcef
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
modules/got_patcher/gt_module.c

index 32e48c190793c8b4729c6165356e65a7b828cc5c..cd6898dfe2ba9cba7779c325eb413ebd79218476 100644 (file)
@@ -63,6 +63,29 @@ static struct bin_data_t _handler_reloc;
 static struct bin_data_t _pthread_init;
 
 
+static void uninit_local_variables(void)
+{
+       swap_dput(_linker_fixup.dentry);
+       _linker_fixup.dentry = NULL;
+       _linker_fixup.off = 0;
+
+       swap_dput(_linker_reloc.dentry);
+       _linker_reloc.dentry = NULL;
+       _linker_reloc.off = 0;
+
+       swap_dput(_handler_fixup.dentry);
+       _handler_fixup.dentry = NULL;
+       _handler_fixup.off = 0;
+
+       swap_dput(_handler_reloc.dentry);
+       _handler_reloc.dentry = NULL;
+       _handler_reloc.off = 0;
+
+       swap_dput(_pthread_init.dentry);
+       _pthread_init.dentry = NULL;
+       _pthread_init.off = 0;
+}
+
 static inline void _lock_probes_list(void)
 {
        mutex_lock(&_linker_probes_lock);
@@ -856,6 +879,7 @@ int gtm_del_by_path(char *path)
                return -EINVAL;
 
        ret = _remove_from_list(_check_by_dentry, dentry);
+       swap_dput(dentry);
 
        return ret;
 }
@@ -1018,12 +1042,7 @@ static void gtm_exit(void)
        gtd_exit();
 
        _clean_linker_probes();
-
-       swap_dput(_handler_fixup.dentry);
-       _handler_fixup.dentry = NULL;
-
-       swap_dput(_handler_reloc.dentry);
-       _handler_reloc.dentry = NULL;
+       uninit_local_variables();
 }
 
 SWAP_LIGHT_INIT_MODULE(NULL, gtm_init, gtm_exit, NULL, NULL);