make check works.
Re-purposing the encryption lock would have been my suggestion as well.
Some context is missing but I assume the patch is okay.
Background: We now have npth aware locks in libgpg-error. Libgcrypt thus got nPth support en passant which lead to the problems with code like
foo = xmalloc (100);
because both, xfree and xmalloc, might be implemented by Libgcrypt and thus employs locks and so may introduce a thread switch,
Note that even xfree uses a lock because it needs to check whether the to be released memory is in one of the secure memory areas.
before that change in libgpg-error the malloc functions were not considered functions triggering a thread switch,