[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PULL v3 06/12] qga: add implementation of guest-get-disks for Linux
From: |
Peter Maydell |
Subject: |
Re: [PULL v3 06/12] qga: add implementation of guest-get-disks for Linux |
Date: |
Thu, 5 Nov 2020 23:50:35 +0000 |
On Tue, 3 Nov 2020 at 02:45, Michael Roth <michael.roth@amd.com> wrote:
>
> From: Tomáš Golembiovský <tgolembi@redhat.com>
>
> The command lists all disks (real and virtual) as well as disk
> partitions. For each disk the list of dependent disks is also listed and
> /dev path is used as a handle so it can be matched with "name" field of
> other returned disk entries. For disk partitions the "dependents" list
> is populated with the the parent device for easier tracking of
> hierarchy.
Hi; Coverity points out a resource leak in this function
(CID 1436130):
> +GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
> +{
> + GuestDiskInfoList *item, *ret = NULL;
> + GuestDiskInfo *disk;
> + DIR *dp = NULL;
> + struct dirent *de = NULL;
> +
> + g_debug("listing /sys/block directory");
> + dp = opendir("/sys/block");
Here we opendir()...
> + if (dp == NULL) {
> + error_setg_errno(errp, errno, "Can't open directory \"/sys/block\"");
> + return NULL;
> + }
> + while ((de = readdir(dp)) != NULL) {
[stuff]
> + }
> + return ret;
...but we forget to closedir() it again.
> +}
thanks
-- PMM
- [PULL v3 11/12] meson: minor simplification, (continued)
- [PULL v3 11/12] meson: minor simplification, Michael Roth, 2020/11/02
- [PULL v3 12/12] qga: add ssh-get-authorized-keys, Michael Roth, 2020/11/02
- [PULL v3 01/12] qga: Rename guest-get-devices return member 'address' to 'id', Michael Roth, 2020/11/02
- [PULL v3 02/12] qga: Use common time encoding for guest-get-devices 'driver-date', Michael Roth, 2020/11/02
- [PULL v3 03/12] qga-win: Fix guest-get-devices error API violations, Michael Roth, 2020/11/02
- [PULL v3 04/12] qga: Flatten simple union GuestDeviceId, Michael Roth, 2020/11/02
- [PULL v3 05/12] qga: add command guest-get-disks, Michael Roth, 2020/11/02
- [PULL v3 06/12] qga: add implementation of guest-get-disks for Linux, Michael Roth, 2020/11/02
- Re: [PULL v3 06/12] qga: add implementation of guest-get-disks for Linux,
Peter Maydell <=
- [PULL v3 07/12] qga: add implementation of guest-get-disks for Windows, Michael Roth, 2020/11/02
- [PULL v3 08/12] glib-compat: add g_unix_get_passwd_entry_qemu(), Michael Roth, 2020/11/02
- Re: [PULL v3 00/12] qemu-ga patch queue for soft-freeze, Peter Maydell, 2020/11/03