From 12e5342e10c384539c8c26f075ce98ebbe887a05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Fri, 8 Jan 2021 07:41:00 -0500 Subject: [PATCH 09/10] qga: fix missing closedir() in qmp_guest_get_disks() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RH-Author: Marc-André Lureau Message-id: <20210108074101.290008-10-marcandre.lureau@redhat.com> Patchwork-id: 100528 O-Subject: [RHEL-8.3.0.z qemu-kvm PATCH 09/10] qga: fix missing closedir() in qmp_guest_get_disks() Bugzilla: 1913818 RH-Acked-by: Miroslav Rezanina RH-Acked-by: Philippe Mathieu-Daudé RH-Acked-by: Stefano Garzarella From: Marc-André Lureau From: Michael Roth We opendir("/sys/block") at the beginning of the function, but we never close it prior to returning. Fixes: Coverity CID 1436130 Fixes: fed3956429d5 ("qga: add implementation of guest-get-disks for Linux") Reported-by: Peter Maydell Cc: Marc-André Lureau Cc: Tomáš Golembiovský Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Michael Roth (cherry-picked from commit b1b9ab1c04d560f86d8da3dfca4d8b21de75fee6) Signed-off-by: Marc-André Lureau Signed-off-by: Danilo C. L. de Paula --- qga/commands-posix.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index af80bb7ccbb..1a9c2cbc3e6 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1384,6 +1384,9 @@ GuestDiskInfoList *qmp_guest_get_disks(Error **errp) get_disk_deps(disk_dir, disk); ret = get_disk_partitions(ret, de->d_name, disk_dir, dev_name); } + + closedir(dp); + return ret; } -- 2.27.0