From 34e522418f7fdd22b0a88fd5402c1d8d1bcb28b1 Mon Sep 17 00:00:00 2001
From: Peter Krempa <pkrempa@redhat.com>
Date: Tue, 2 Feb 2021 15:57:06 +0100
Subject: [PATCH] virNetLibsshSessionAuthAddPrivKeyAuth: Don't unlock unlocked
 'sess' on error
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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>
---
 src/rpc/virnetlibsshsession.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c
index 959a16a6a9..ed697c7ce4 100644
--- a/src/rpc/virnetlibsshsession.c
+++ b/src/rpc/virnetlibsshsession.c
@@ -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);