[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [Qemu-devel] [PATCH] qga/commands-posix: Fix resource
From: |
Shannon Zhao |
Subject: |
Re: [Qemu-trivial] [Qemu-devel] [PATCH] qga/commands-posix: Fix resource leak |
Date: |
Sat, 14 Mar 2015 17:14:31 +0800 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 |
On 2015/3/14 14:54, Stefan Weil wrote:
> Am 14.03.2015 um 04:30 schrieb Shannon Zhao:
>> It's detected by coverity. Close the dirfd.
>>
>> Signed-off-by: Shannon Zhao <address@hidden>
>> Signed-off-by: Shannon Zhao <address@hidden>
>> ---
>> qga/commands-posix.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
>> index d5bb5cb..cbf1c80 100644
>> --- a/qga/commands-posix.c
>> +++ b/qga/commands-posix.c
>> @@ -2285,6 +2285,7 @@ GuestMemoryBlockInfo
>> *qmp_guest_get_memory_block_info(Error **errp)
>> ga_read_sysfs_file(dirfd, "block_size_bytes", buf, 20, &local_err);
>
> Why not closing it here? It's no longer needed.
>
Ok, will fix this.
Thanks,
Shannon
>> if (local_err) {
>> g_free(buf);
>> + close(dirfd);
>> error_propagate(errp, local_err);
>> return NULL;
>> }
>> @@ -2293,6 +2294,7 @@ GuestMemoryBlockInfo
>> *qmp_guest_get_memory_block_info(Error **errp)
>> info->size = strtol(buf, NULL, 16); /* the unit is bytes */
>> g_free(buf);
>> + close(dirfd);
>> return info;
>> }
>
>
> .
>