Skip to contentSkip to conversation

qga: fix missing closedir() in qmp_guest_get_disks()

PATCH In review Michael Roth 2 participants 2 messages Nov 8, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qga: fix missing closedir() in qmp_guest_get_disks()

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")
Cc Marc-André Lureau <[email protected]>
Cc Tomáš Golembiovský <[email protected]>
---
 qga/commands-posix.c | 3 +++
 1 file changed, 3 insertions(+)
qga/commands-posix.c +3 -0
index 3711080d07..12c1ba5ef7 100644
@@ -1443,6 +1443,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;
 }
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · 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")
Cc Marc-André Lureau <[email protected]>
Cc Tomáš Golembiovský <[email protected]>
Quoted 3 lines
---
 qga/commands-posix.c | 3 +++
 1 file changed, 3 insertions(+)