'sess->authPath' is modified before locking the 'sess' object.
Additionally on failure of 'virAuthGetConfigFilePathURI' 'sess' would be
unlocked even when it was not yet locked.
Fixes: 273745b43122a77adf8c73b2e0a852ac42387349
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
{
virNetSSHAuthMethod *auth;
+ virObjectLock(sess);
+
if (uri) {
VIR_FREE(sess->authPath);
- if (virAuthGetConfigFilePathURI(uri, &sess->authPath) < 0)
- goto error;
+ if (virAuthGetConfigFilePathURI(uri, &sess->authPath) < 0) {
+ virObjectUnlock(sess);
+ return -1;
+ }
}
- virObjectLock(sess);
-
if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
goto error;