Set static values to NULL after use 30/128030/1
authorDmitry Kovalenko <d.kovalenko@samsung.com>
Tue, 7 Mar 2017 07:40:00 +0000 (10:40 +0300)
committerDmitry Kovalenko <d.kovalenko@samsung.com>
Thu, 4 May 2017 06:34:47 +0000 (09:34 +0300)
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
preload/preload_module.c
uihv/uihv_module.c

index af6b233..5625dbe 100644 (file)
@@ -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;
        }
 }
 
index 8c6f38d..0ab869f 100644 (file)
@@ -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);
index eeb8ab3..11710a6 100644 (file)
@@ -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();
 }