Changeset b454a22 in mainline


Ignore:
Timestamp:
2016-07-03T22:11:52Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
659ebd86
Parents:
92c07dc
Message:

libdrv: Do proper reference counting on fun in driver_connection_gen()

driver_connection_gen() should add a reference when it starts to work
with fun and drop it when before it returns. Otherwise it is possible
for fun to become a dangling pointer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/driver.c

    r92c07dc rb454a22  
    335335        fibril_mutex_lock(&functions_mutex);
    336336        ddf_fun_t *fun = driver_get_function(handle);
     337        if (fun != NULL)
     338                fun_add_ref(fun);
    337339        fibril_mutex_unlock(&functions_mutex);
    338         /* XXX Need a lock on fun */
    339340       
    340341        if (fun == NULL) {
     
    348349                /* Driver has a custom connection handler. */
    349350                (*fun->conn_handler)(iid, icall, (void *)fun);
     351                fun_del_ref(fun);
    350352                return;
    351353        }
     
    362364       
    363365        async_answer_0(iid, ret);
    364         if (ret != EOK)
     366        if (ret != EOK) {
     367                fun_del_ref(fun);
    365368                return;
     369        }
    366370       
    367371        while (true) {
     
    376380                                (*fun->ops->close)(fun);
    377381                        async_answer_0(callid, EOK);
     382                        fun_del_ref(fun);
    378383                        return;
    379384                }
Note: See TracChangeset for help on using the changeset viewer.