lkml.org 
[lkml]   [2021]   [Jan]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] iommu/intel: Fix memleak in intel_irq_remapping_alloc
From
Date
Hi,

On 2021/1/2 17:50, Dinghao Liu wrote:
> When irq_domain_get_irq_data() or irqd_cfg() fails
> meanwhile i == 0, data allocated by kzalloc() has not
> been freed before returning, which leads to memleak.
>
> Fixes: b106ee63abccb ("irq_remapping/vt-d: Enhance Intel IR driver to support hierarchical irqdomains")
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
> drivers/iommu/intel/irq_remapping.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/iommu/intel/irq_remapping.c b/drivers/iommu/intel/irq_remapping.c
> index aeffda92b10b..cdaeed36750f 100644
> --- a/drivers/iommu/intel/irq_remapping.c
> +++ b/drivers/iommu/intel/irq_remapping.c
> @@ -1354,6 +1354,8 @@ static int intel_irq_remapping_alloc(struct irq_domain *domain,
> irq_cfg = irqd_cfg(irq_data);
> if (!irq_data || !irq_cfg) {
> ret = -EINVAL;
> + kfree(data);
> + data = NULL;

Do you need to check (i == 0) here? @data will not be used anymore as it
goes to out branch, why setting it to NULL here?

Best regards,
baolu

> goto out_free_data;
> }
>
>

\
 
 \ /
  Last update: 2021-01-03 03:42    [W:0.041 / U:0.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site