From 7913a4ff4cb7167ecd9162ef51e30dcf85d551a7 Mon Sep 17 00:00:00 2001 From: Dmitry Kovalenko Date: Tue, 7 Mar 2017 10:40:00 +0300 Subject: [PATCH] Set static values to NULL after use In case of built-in mode these variables should be reinitialized otherwise it leads to double put_dentry Change-Id: I0002c6186c9fcafa811bb8c48ccbc8d5137c7e4b --- got_patcher/gt_module.c | 3 +++ preload/preload_module.c | 8 ++++++-- uihv/uihv_module.c | 8 ++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/got_patcher/gt_module.c b/got_patcher/gt_module.c index af6b233..5625dbe 100644 --- a/got_patcher/gt_module.c +++ b/got_patcher/gt_module.c @@ -1083,12 +1083,15 @@ 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; } } diff --git a/preload/preload_module.c b/preload/preload_module.c index 8c6f38d..0ab869f 100644 --- a/preload/preload_module.c +++ b/preload/preload_module.c @@ -450,8 +450,10 @@ int pm_set_handler(char *path) struct dentry *dentry; int ret; - if (handler_dentry != NULL) + if (handler_dentry != NULL) { swap_put_dentry(handler_dentry); + handler_dentry = NULL; + } dentry = swap_get_dentry(path); @@ -530,8 +532,10 @@ static void pm_exit(void) pc_exit(); pd_exit(); - if (handler_dentry != NULL) + if (handler_dentry != NULL) { swap_put_dentry(handler_dentry); + handler_dentry = NULL; + } } SWAP_LIGHT_INIT_MODULE(NULL, pm_init, pm_exit, NULL, NULL); diff --git a/uihv/uihv_module.c b/uihv/uihv_module.c index eeb8ab3..11710a6 100644 --- a/uihv/uihv_module.c +++ b/uihv/uihv_module.c @@ -92,8 +92,10 @@ int uihv_set_handler(char *path) struct dentry *dentry; int ret; - if (uihv_dentry != NULL) + if (uihv_dentry != NULL) { swap_put_dentry(uihv_dentry); + uihv_dentry = NULL; + } dentry = swap_get_dentry(path); if (dentry == NULL) { @@ -217,8 +219,10 @@ static int uihv_init(void) static void uihv_exit(void) { - if (uihv_dentry != NULL) + if (uihv_dentry != NULL) { swap_put_dentry(uihv_dentry); + uihv_dentry = NULL; + } uihv_dfs_exit(); } -- 2.7.4