Skip to content

Commit

Permalink
monitor: fix qmp_getfd() fd leak in error case
Browse files Browse the repository at this point in the history
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: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
  • Loading branch information
stefanhaRH authored and Luiz Capitulino committed Apr 25, 2014
1 parent 1b7a0f7 commit 0b9f0e2
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions monitor.c
Expand Up @@ -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;
Expand Down

0 comments on commit 0b9f0e2

Please sign in to comment.