Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset e6fc486 in mainline


Ignore:
Timestamp:
2018-11-22T16:55:28Z (3 years ago)
Author:
Jakub Jermar <jakub@…>
Parents:
21d3201
Message:

Fix devman function reference counting

After commit 498ced18a4, create_fun_node() returns a fun pointer with an
implicit reference. Adding an extra reference for creation thus adds a
reference that will never be dropped and the function object will be
leaked.

This commit fixes the reference counting issue and also adds the missing
check to the call to insert_fun_node().

Location:
uspace/srv/devman
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/devtree.c

    r21d3201 re6fc486  
    144144        }
    145145
    146         fun_add_ref(fun);
    147         insert_fun_node(tree, fun, str_dup(""), NULL);
     146        if (!insert_fun_node(tree, fun, str_dup(""), NULL)) {
     147                fun_del_ref(fun);       /* fun is destroyed */
     148                fibril_rwlock_write_unlock(&tree->rwlock);
     149                return false;
     150        }
    148151
    149152        match_id_t *id = create_match_id();
  • uspace/srv/devman/drv_conn.c

    r21d3201 re6fc486  
    284284
    285285        fun_node_t *fun = create_fun_node();
    286         /* One reference for creation, one for us */
    287         fun_add_ref(fun);
     286        /*
     287         * Hold a temporary reference while we work with fun. The reference from
     288         * create_fun_node() moves to the device tree.
     289         */
    288290        fun_add_ref(fun);
    289291        fun->ftype = ftype;
     
    300302                fun_busy_unlock(fun);
    301303                fun_del_ref(fun);
    302                 delete_fun_node(fun);
     304                fun_del_ref(fun);       /* fun is destroyed */
    303305                async_answer_0(call, ENOMEM);
    304306                return;
Note: See TracChangeset for help on using the changeset viewer.