[PATCH 0/2] x86/xen: Fix memory leak issue

Xiu Jianfeng posted 2 patches 2 weeks, 5 days ago
Failed in applying to current master (apply log)
There is a newer version of this series
arch/x86/xen/smp.c      | 16 ++++++++++++----
arch/x86/xen/smp_pv.c   |  8 ++++++--
arch/x86/xen/spinlock.c |  3 ++-
3 files changed, 20 insertions(+), 7 deletions(-)
[PATCH 0/2] x86/xen: Fix memory leak issue
Posted by Xiu Jianfeng 2 weeks, 5 days ago
The new string allocated by kasprintf() is leaked on error path

Xiu Jianfeng (2):
  x86/xen: Fix memory leak in xen_smp_intr_init{_pv}()
  x86/xen: Fix memory leak in xen_init_lock_cpu()

 arch/x86/xen/smp.c      | 16 ++++++++++++----
 arch/x86/xen/smp_pv.c   |  8 ++++++--
 arch/x86/xen/spinlock.c |  3 ++-
 3 files changed, 20 insertions(+), 7 deletions(-)

-- 
2.17.1
Re: [PATCH 0/2] x86/xen: Fix memory leak issue
Posted by Juergen Gross 2 weeks, 1 day ago
On 19.11.22 09:59, Xiu Jianfeng wrote:
> The new string allocated by kasprintf() is leaked on error path
> 
> Xiu Jianfeng (2):
>    x86/xen: Fix memory leak in xen_smp_intr_init{_pv}()
>    x86/xen: Fix memory leak in xen_init_lock_cpu()
> 
>   arch/x86/xen/smp.c      | 16 ++++++++++++----
>   arch/x86/xen/smp_pv.c   |  8 ++++++--
>   arch/x86/xen/spinlock.c |  3 ++-
>   3 files changed, 20 insertions(+), 7 deletions(-)
> 

Hmm, I think it would make more sense to always store the name generated
via kasprintf() in the percpu variable (independently from succeeding to
bind the irq), and in the related free function to always kfree() it and
set it to NULL again.

This would result in less code.


Juergen
Re: [PATCH 0/2] x86/xen: Fix memory leak issue
Posted by xiujianfeng 2 weeks, 1 day ago
Hi,

在 2022/11/23 23:23, Juergen Gross 写道:
> On 19.11.22 09:59, Xiu Jianfeng wrote:
>> The new string allocated by kasprintf() is leaked on error path
>>
>> Xiu Jianfeng (2):
>>    x86/xen: Fix memory leak in xen_smp_intr_init{_pv}()
>>    x86/xen: Fix memory leak in xen_init_lock_cpu()
>>
>>   arch/x86/xen/smp.c      | 16 ++++++++++++----
>>   arch/x86/xen/smp_pv.c   |  8 ++++++--
>>   arch/x86/xen/spinlock.c |  3 ++-
>>   3 files changed, 20 insertions(+), 7 deletions(-)
>>
> 
> Hmm, I think it would make more sense to always store the name generated
> via kasprintf() in the percpu variable (independently from succeeding to
> bind the irq), and in the related free function to always kfree() it and
> set it to NULL again.
> 
> This would result in less code.

Thanks, It's good to me, already sent v2.
> 
> 
> Juergen