[libvirt] [PATCH 1/3] LXC: avoid useless memory free in lxcContainerIdentifyCGroups
Gao feng
gaofeng at cn.fujitsu.com
Tue Jun 19 01:24:23 UTC 2012
于 2012年06月18日 14:57, Osier Yang 写道:
> On 2012年06月15日 15:41, Gao feng wrote:
>> when lxcContainerIdentifyCGroups failed, lxcContainerSetupPivortRoot
>> and lxcContainerSetupExtraMounts will free the memory that allocated
>> in lxcContainerIdentifyCGroups.
>>
>> So we need not call lxcContainerCGroupFree when
>> lxcContainerIdentifyCGroups failed.
>>
>> Signed-off-by: Gao feng<gaofeng at cn.fujitsu.com>
>> ---
>> src/lxc/lxc_container.c | 7 +++----
>> 1 files changed, 3 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
>> index 4fbceb4..87de463 100644
>> --- a/src/lxc/lxc_container.c
>> +++ b/src/lxc/lxc_container.c
>> @@ -1236,17 +1236,16 @@ static int lxcContainerIdentifyCGroups(struct lxcContainerCGroup **mountsret,
>> }
>> }
>>
>> - *mountsret = mounts;
>> - *nmountsret = nmounts;
>> ret = 0;
>>
>> cleanup:
>> + *mountsret = mounts;
>> + *nmountsret = nmounts;
>> +
>> closedir(dh);
>> endmntent(procmnt);
>> VIR_FREE(path);
>>
>> - if (ret< 0)
>> - lxcContainerCGroupFree(mounts, nmounts);
>> return ret;
>> }
>>
>
> NACK. Personally I think removing the duplicate free() in the callers
> (only lxcContainerSetupPivortRoot and lxcContainerSetupExtraMounts
> now) is better. No reason to keep an allocated memory while the function
> itself fails.
Got it, I will resend this patch,
thanks.
More information about the libvir-list
mailing list