OpenSolaris

Printable Version Enter a New Search
Bug ID 6559699
Synopsis sharemgr: sa_scf_init() leaks scf instance and scope
State 10-Fix Delivered (Fix available in build)
Category:Subcategory utility:filesystem
Keywords
Responsible Engineer Doug Mccallum
Reported Against
Duplicate Of
Introduced In solaris_nevada
Commit to Fix snv_66
Fixed In snv_66
Release Fixed solaris_nevada(snv_66) , solaris_10u6(s10u6_01) (Bug ID:2156372)
Related Bugs
Submit Date 20-May-2007
Last Update Date 29-April-2008
Description
In sa_scf_init(), we have:

                    handle->scope = scf_scope_create(handle->handle);
                    handle->service = scf_service_create(handle->handle);
                    handle->pg = scf_pg_create(handle->handle);
                    handle->instance = scf_instance_create(handle->handle);

Besides the fact that it doesn't seem like we check the return
values for these functions, we also have the following in sa_scf_fini():

void
sa_scf_fini(scfutilhandle_t *handle)
{
        if (handle != NULL) {
            int unbind = 0;
            if (handle->scope != NULL) {
                unbind = 1;
                scf_scope_destroy(handle->scope);
            }
            if (handle->service != NULL)
                    scf_service_destroy(handle->service);
            if (handle->pg != NULL)
                scf_pg_destroy(handle->pg);
            if (handle->handle != NULL) {
                handle->scf_state = SCH_STATE_UNINIT;
                if (unbind)
                    (void) scf_handle_unbind(handle->handle);
                scf_handle_destroy(handle->handle);
            }
            free(handle);
        }
}

Notice that we never free 'instance' or 'scope'.
Work Around
N/A
Comments
N/A