[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 06/10] target/i386/cpu: Fix memleak in x86_cpu_class_check
From: |
Pan Nengyuan |
Subject: |
Re: [PATCH v2 06/10] target/i386/cpu: Fix memleak in x86_cpu_class_check_missing_features |
Date: |
Wed, 2 Sep 2020 08:55:58 +0800 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 |
On 2020/9/1 20:03, Markus Armbruster wrote:
> Pan Nengyuan <pannengyuan@huawei.com> writes:
>
>> 'err' forgot to free in x86_cpu_class_check_missing_features error path.
>> Fix that.
>>
>> Reported-by: Euler Robot <euler.robot@huawei.com>
>> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
>> Reviewed-by: Li Qiang <liq3ea@gmail.com>
>> ---
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Cc: Richard Henderson <rth@twiddle.net>
>> Cc: Eduardo Habkost <ehabkost@redhat.com>
>> ---
>> - V2: no changes in v2.
>> ---
>> target/i386/cpu.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
>> index 588f32e136..4678aac0b4 100644
>> --- a/target/i386/cpu.c
>> +++ b/target/i386/cpu.c
>> @@ -4872,6 +4872,7 @@ static void
>> x86_cpu_class_check_missing_features(X86CPUClass *xcc,
> x86_cpu_expand_features(xc, &err);
> if (err) {
> /* Errors at x86_cpu_expand_features should never happen,
> * but in case it does, just report the model as not
> * runnable at all using the "type" property.
> */
> strList *new = g_new0(strList, 1);
>> new->value = g_strdup("type");
>> *next = new;
>> next = &new->next;
>> + error_free(err);
>> }
>>
>> x86_cpu_filter_features(xc, false);
>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
>
> Recommended cleanup: change x86_cpu_filter_features() to return true on
> success, false on failure, then pass NULL here and check the return
> value. Can be done on top.
>
Agree with you, 'err' is not used, we can pass NULL here.
BTW, I think the func you mentioned shoule be x86_cpu_expand_features(), not
x86_cpu_filter_features()?
Thanks.
> .
>