Skip to content

smartcard: Cancel cancellable when stopping

Marek Kašík requested to merge nssrwlock-lockread-util-crash into master

There is quite a lot of crashes in NSSRWLock_LockRead_Util() and NSSRWLock_UnlockRead_Util() for smartcard plugin filed in RH bugzilla. See https://bugzilla.redhat.com/show_bug.cgi?id=1646359, https://bugzilla.redhat.com/show_bug.cgi?id=1688791 and their duplicates.

I think that these are caused by not cancelling self->cancellable of GsdSmartcardManager at gsd_smartcard_manager_stop(). Some callbacks are still called after unload_nss() which clears a SECMODListLock which is used by SECMOD_GetReadLock() / SECMOD_ReleaseReadLock(). And this leads to crashes in NSSRWLock_LockRead_Util() and NSSRWLock_UnlockRead_Util() probably.

I could not test this but I think that this should fix it.

The commit also checks for return value of g_cancellable_connect(), whether the cancellable is already cancelled.

Merge request reports