admin: fix devices not reset
authorYun-Hao Chung <howardchung@chromium.org>
Fri, 12 Nov 2021 04:01:49 +0000 (12:01 +0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:38 +0000 (19:08 +0530)
When |admin_policy_remove| is called, we set |devices| to NULL but never
set it back until |admin_init|. This makes admin lost track of current
registered device interface, so the next |admin_policy_removed| will not
be able to unregister those interfaces.

Reviewed-by: Archie Pusaka <apusaka@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
plugins/admin.c

index df06d23..e6db86e 100644 (file)
@@ -496,6 +496,9 @@ static int admin_policy_adapter_probe(struct btd_adapter *adapter)
 {
        const char *adapter_path;
 
+       if (!devices)
+               devices = queue_new();
+
        if (policy_data) {
                btd_warn(policy_data->adapter_id,
                                                "Policy data already exists");
@@ -622,7 +625,6 @@ static int admin_init(void)
        DBG("");
 
        dbus_conn = btd_get_dbus_connection();
-       devices = queue_new();
 
        return btd_register_adapter_driver(&admin_policy_driver);
 }