session: Policy register should check callback existence
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Wed, 31 Oct 2012 09:33:30 +0000 (10:33 +0100)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Mon, 5 Nov 2012 12:42:17 +0000 (14:42 +0200)
Let's ensure that the policy plugin has all necessary callbacks
installed when connman_session_policy_register() is called. The rest
of the code expects that the create() and destroy() callbacks exist
whenever a plugin is used.

src/session.c

index c981bef..2b06e3f 100644 (file)
@@ -314,6 +314,9 @@ int connman_session_policy_register(struct connman_session_policy *policy)
 {
        DBG("name %s", policy->name);
 
+       if (policy->create == NULL || policy->destroy == NULL)
+               return -EINVAL;
+
        policy_list = g_slist_insert_sorted(policy_list, policy,
                                                compare_priority);