qemu-devel
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]