I think that gphoto2_backend->lock is also not NULL, as g_mutex_clear() derefs it: g_mutex_impl_free (mutex->p); it seems it's gphoto2_backend->lock->p which is NULL then, i. e. the mutex was not initialized properly.
The only access to this aside from the _lock()/_unlock() calls is in do_mount() line 1715, i. e. it gets initialized _after_ release_device() is called (which tries to free it again).
I think that gphoto2_ backend- >lock is also not NULL, as g_mutex_clear() derefs it: g_mutex_impl_free (mutex->p); it seems it's gphoto2_ backend- >lock-> p which is NULL then, i. e. the mutex was not initialized properly.
The only access to this aside from the _lock()/_unlock() calls is in do_mount() line 1715, i. e. it gets initialized _after_ release_device() is called (which tries to free it again).