session_policy_local: Do not free policy on load error
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Tue, 9 Apr 2013 16:13:12 +0000 (18:13 +0200)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Thu, 18 Apr 2013 05:44:04 +0000 (08:44 +0300)
We should not unref the policy on parsing errors becase the policy
lifetime is attached to the lifetime of the file. When the file
is removed we remove it from the hash table.

plugins/session_policy_local.c

index fa8349f..aa734a1 100644 (file)
@@ -390,6 +390,7 @@ static void notify_handler(struct inotify_event *event,
                                         const char *ident)
 {
        struct policy_data *policy;
+       int err;
 
        if (ident == NULL)
                return;
@@ -411,8 +412,10 @@ static void notify_handler(struct inotify_event *event,
        if (event->mask & IN_MODIFY) {
                connman_info("Policy modifed for '%s'", ident);
 
-               if (load_policy(policy) < 0) {
-                       remove_policy(policy);
+               err = load_policy(policy);
+               if (err < 0) {
+                       connman_warn("Loading policy file '%s' failed with %s",
+                                       ident, strerror(-err));
                        return;
                }
        }