virNetLibsshSessionAuthAddPrivKeyAuth: Don't unlock unlocked 'sess' on error

The check whether @keyfile is non-NULL is before locking @sess, but uses
the 'error' label which unlocks '@sess'.

While touching the error path, update the error message to be on one
line.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Peter Krempa 2021-02-02 15:57:06 +01:00
parent 26fedf9218
commit 34e522418f

View File

@ -1020,10 +1020,8 @@ virNetLibsshSessionAuthAddPrivKeyAuth(virNetLibsshSessionPtr sess,
if (!keyfile) {
virReportError(VIR_ERR_LIBSSH, "%s",
_("Key file path must be provided "
"for private key authentication"));
ret = -1;
goto error;
_("Key file path must be provided for private key authentication"));
return -1;
}
virObjectLock(sess);