[PATCH v2 05/27] virNetLibsshSessionAuthAddPrivKeyAuth: Don't unlock unlocked 'sess' on error

Peter Krempa pkrempa at redhat.com
Tue Feb 2 16:55:42 UTC 2021


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 at 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);
-- 
2.29.2




More information about the libvir-list mailing list