[Pcsclite-muscle] [PATCH] Fix invalid pthread_mutex_unlock in CreateContextThread

Ludovic Rousseau ludovic.rousseau at gmail.com
Thu Oct 2 11:25:21 UTC 2014


2014-10-02 12:11 GMT+02:00 Giuseppe M <gdm23 at iragan.org>:
> Hello Ludovic,

Hello,

> please merge patch in attachment, the issue was found using valgrind.

I don't think this patch is correct.

The original code is:

    (void)pthread_mutex_lock(&contextsList_lock);

    listSize = list_size(&contextsList);
    if (listSize >= contextMaxThreadCounter)
    {
        Log2(PCSC_LOG_CRITICAL, "Too many context running: %d", listSize);
        goto out;
    }

[...]
out:
    (void)pthread_mutex_unlock(&contextsList_lock);


You HAVE to unlock in the if since the mutex lock is done before.


What is exactly the problem reported by valgrind?

Regards,

-- 
 Dr. Ludovic Rousseau



More information about the Pcsclite-muscle mailing list