Skip to content

Potential error(e.g., deadlock) due to the unreleased lock&netcam->mutex #1363

@jenny-cheung

Description

@jenny-cheung

Dear developers:
First, thank you for your checking. In the method, netcam_cleanup, the lock &netcam->mutex may not be released correctly if the branch condition satisfies. The fix is to insert the pthread_mutex_unlock(&netcam->mutex); before returning.

pthread_mutex_lock(&netcam->mutex);

if (netcam->cnt->netcam == NULL) {

void netcam_cleanup(netcam_context_ptr netcam, int init_retry_flag)
{
    struct timespec waittime;

    if (!netcam) {
        return;
    }

    /*
     * This 'lock' is just a bit of "defensive" programming.  It should
     * only be necessary if the routine is being called from different
     * threads, but in our Motion design, it should only be called from
     * the motion main-loop.
     */
    pthread_mutex_lock(&netcam->mutex);

    if (netcam->cnt->netcam == NULL) {
        return; //return but the lock is not released
    }
...;
}

Best,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions