Skip to contentSkip to conversation

RDMA/hfi1: Fix memory leak in _dev_comp_vect_mappings_create

PATCH Applied Kamal Heib 3 participants 3 messages Feb 5, 2020 – Feb 11, 2020

Subsystems (2)
lore
Share & tools
lore

Kamal Heib

author
#0 lore raw

PATCH 1/1 RDMA/hfi1: Fix memory leak in _dev_comp_vect_mappings_create

Make sure to free the allocated cpumask_var_t's to avoid the following reported memory leak by kmemleak:

$ cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff8897f812d6a8 (size 8):
  comm "kworker/1:1", pid 347, jiffies 4294751400 (age 101.703s)
  hex dump (first 8 bytes):
    00 00 00 00 00 00 00 00                          ........
  backtrace:
    [<00000000bff49664>] alloc_cpumask_var_node+0x4c/0xb0
    [<0000000075d3ca81>] hfi1_comp_vectors_set_up+0x20f/0x800 [hfi1]
    [<0000000098d420df>] hfi1_init_dd+0x3311/0x4960 [hfi1]
    [<0000000071be7e52>] init_one+0x25e/0xf10 [hfi1]
    [<000000005483d4c2>] local_pci_probe+0xd4/0x180
    [<000000007c3cbc6e>] work_for_cpu_fn+0x51/0xa0
    [<000000001d626905>] process_one_work+0x8f0/0x17b0
    [<000000007e569e7e>] worker_thread+0x536/0xb50
    [<00000000fd39a4a5>] kthread+0x30c/0x3d0
    [<0000000056f2edb3>] ret_from_fork+0x3a/0x50
Fixes 5d18ee67d4c1 ("IB/{hfi1, rdmavt, qib}: Implement CQ completion vector support")
---
 drivers/infiniband/hw/hfi1/affinity.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/infiniband/hw/hfi1/affinity.c +2 -0
index c142b23bb401..1aeea5d65c01 100644
@@ -479,6 +479,8 @@ static int _dev_comp_vect_mappings_create(struct hfi1_devdata *dd,
 			  rvt_get_ibdev_name(&(dd)->verbs_dev.rdi), i, cpu);
 	}
 
+	free_cpumask_var(available_cpus);
+	free_cpumask_var(non_intr_cpus);
 	return 0;
 
 fail:
Signature · 1 line
2.21.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 32 lines · Kamal Heib

Make sure to free the allocated cpumask_var_t's to avoid the following reported memory leak by kmemleak:

$ cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff8897f812d6a8 (size 8):
   comm "kworker/1:1", pid 347, jiffies 4294751400 (age 101.703s)
   hex dump (first 8 bytes):
     00 00 00 00 00 00 00 00                          ........
   backtrace:
     [<00000000bff49664>] alloc_cpumask_var_node+0x4c/0xb0
     [<0000000075d3ca81>] hfi1_comp_vectors_set_up+0x20f/0x800 [hfi1]
     [<0000000098d420df>] hfi1_init_dd+0x3311/0x4960 [hfi1]
     [<0000000071be7e52>] init_one+0x25e/0xf10 [hfi1]
     [<000000005483d4c2>] local_pci_probe+0xd4/0x180
     [<000000007c3cbc6e>] work_for_cpu_fn+0x51/0xa0
     [<000000001d626905>] process_one_work+0x8f0/0x17b0
     [<000000007e569e7e>] worker_thread+0x536/0xb50
     [<00000000fd39a4a5>] kthread+0x30c/0x3d0
     [<0000000056f2edb3>] ret_from_fork+0x3a/0x50
Fixes 5d18ee67d4c1 ("IB/{hfi1, rdmavt, qib}: Implement CQ completion vector support")
---
  drivers/infiniband/hw/hfi1/affinity.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/infiniband/hw/hfi1/affinity.c +0 -0
index c142b23bb401..1aeea5d65c01 100644

drivers/infiniband/hw/hfi1/affinity.c static int _dev_comp_vect_mappings_create(struct hfi1_devdata *dd, · line 486

Quoted 8 lines
drivers/infiniband/hw/hfi1/affinity.c +2 -0
@@ -479,6 +479,8 @@ static int _dev_comp_vect_mappings_create(struct hfi1_devdata *dd,
  			  rvt_get_ibdev_name(&(dd)->verbs_dev.rdi), i, cpu);
  	}
 
+	free_cpumask_var(available_cpus);
+	free_cpumask_var(non_intr_cpus);
  	return 0;
 
  fail:

Perhaps this should also target stable kernel?

#2 lore raw
In reply to Kamal Heib
Quoted 20 lines · Kamal Heib

Make sure to free the allocated cpumask_var_t's to avoid the following reported memory leak by kmemleak:

$ cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff8897f812d6a8 (size 8):
  comm "kworker/1:1", pid 347, jiffies 4294751400 (age 101.703s)
  hex dump (first 8 bytes):
    00 00 00 00 00 00 00 00                          ........
  backtrace:
    [<00000000bff49664>] alloc_cpumask_var_node+0x4c/0xb0
    [<0000000075d3ca81>] hfi1_comp_vectors_set_up+0x20f/0x800 [hfi1]
    [<0000000098d420df>] hfi1_init_dd+0x3311/0x4960 [hfi1]
    [<0000000071be7e52>] init_one+0x25e/0xf10 [hfi1]
    [<000000005483d4c2>] local_pci_probe+0xd4/0x180
    [<000000007c3cbc6e>] work_for_cpu_fn+0x51/0xa0
    [<000000001d626905>] process_one_work+0x8f0/0x17b0
    [<000000007e569e7e>] worker_thread+0x536/0xb50
    [<00000000fd39a4a5>] kthread+0x30c/0x3d0
    [<0000000056f2edb3>] ret_from_fork+0x3a/0x50
Quoted 6 lines
Fixes 5d18ee67d4c1 ("IB/{hfi1, rdmavt, qib}: Implement CQ completion vector support")
---
 drivers/infiniband/hw/hfi1/affinity.c | 2 ++
 1 file changed, 2 insertions(+)

Applied to for-rc, thanks

Jason