Commit 0b9f0e2f authored by Stefan Hajnoczi's avatar Stefan Hajnoczi Committed by Luiz Capitulino
Browse files

monitor: fix qmp_getfd() fd leak in error case



qemu_chr_fe_get_msgfd() transfers ownership of the file descriptor to
the caller.  Therefore all code paths in qmp_getfd() should either
register the file descriptor somewhere or close it.

Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
Signed-off-by: default avatarLuiz Capitulino <lcapitulino@redhat.com>
parent 1b7a0f75
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2228,6 +2228,7 @@ void qmp_getfd(const char *fdname, Error **errp)
    }

    if (qemu_isdigit(fdname[0])) {
        close(fd);
        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "fdname",
                  "a name not starting with a digit");
        return;