From 0b9f0e2fd7c5070fa06cd6bd5ec69055e3a7d2b1 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Thu, 24 Apr 2014 13:58:18 +0200 Subject: 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: Stefan Hajnoczi Reviewed-by: Markus Armbruster Signed-off-by: Luiz Capitulino --- monitor.c | 1 + 1 file changed, 1 insertion(+) (limited to 'monitor.c') diff --git a/monitor.c b/monitor.c index 9ad857820b..1266ba06fb 100644 --- a/monitor.c +++ b/monitor.c @@ -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; -- cgit v1.2.3