android_kernel_motorola_sm6225/drivers/infiniband/hw
Kaike Wan d03460035f IB/hfi1: Fix memory leaks in sysfs registration and unregistration
commit 5c15abc4328ad696fa61e2f3604918ed0c207755 upstream.

When the hfi1 driver is unloaded, kmemleak will report the following
issue:

unreferenced object 0xffff8888461a4c08 (size 8):
comm "kworker/0:0", pid 5, jiffies 4298601264 (age 2047.134s)
hex dump (first 8 bytes):
73 64 6d 61 30 00 ff ff sdma0...
backtrace:
[<00000000311a6ef5>] kvasprintf+0x62/0xd0
[<00000000ade94d9f>] kobject_set_name_vargs+0x1c/0x90
[<0000000060657dbb>] kobject_init_and_add+0x5d/0xb0
[<00000000346fe72b>] 0xffffffffa0c5ecba
[<000000006cfc5819>] 0xffffffffa0c866b9
[<0000000031c65580>] 0xffffffffa0c38e87
[<00000000e9739b3f>] local_pci_probe+0x41/0x80
[<000000006c69911d>] work_for_cpu_fn+0x16/0x20
[<00000000601267b5>] process_one_work+0x171/0x380
[<0000000049a0eefa>] worker_thread+0x1d1/0x3f0
[<00000000909cf2b9>] kthread+0xf8/0x130
[<0000000058f5f874>] ret_from_fork+0x35/0x40

This patch fixes the issue by:

- Releasing dd->per_sdma[i].kobject in hfi1_unregister_sysfs().
  - This will fix the memory leak.

- Calling kobject_put() to unwind operations only for those entries in
   dd->per_sdma[] whose operations have succeeded (including the current
   one that has just failed) in hfi1_verbs_register_sysfs().

Cc: <stable@vger.kernel.org>
Fixes: 0cb2aa690c ("IB/hfi1: Add sysfs interface for affinity setup")
Link: https://lore.kernel.org/r/20200326163807.21129.27371.stgit@awfm-01.aw.intel.com
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Kaike Wan <kaike.wan@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-13 10:45:11 +02:00
..
bnxt_re RDMA/bnxt_re: Add missing spin lock initialization 2020-01-27 14:49:59 +01:00
cxgb3 RDMA/providers: Remove pointless functions 2018-07-30 20:31:54 -06:00
cxgb4 iw_cxgb4: use tos when finding ipv6 routes 2020-01-27 14:50:21 +01:00
hfi1 IB/hfi1: Fix memory leaks in sysfs registration and unregistration 2020-04-13 10:45:11 +02:00
hns RDMA/hns: bugfix for slab-out-of-bounds when loading hip08 driver 2020-01-27 14:51:04 +01:00
i40iw RDMA/i40iw: Fix incorrect iterator type 2019-11-20 18:46:59 +01:00
mlx4 IB/mlx4: Fix memory leak in add_gid error flow 2020-02-14 16:33:22 -05:00
mlx5 RDMA/mlx5: Block delay drop to unprivileged users 2020-04-02 15:28:18 +02:00
mthca IB/mthca: Fix error return code in __mthca_init_one() 2019-11-24 08:20:01 +01:00
nes RDMA/providers: Remove pointless functions 2018-07-30 20:31:54 -06:00
ocrdma RDMA/ocrdma: Fix out of bounds index check in query pkey 2020-01-27 14:50:12 +01:00
qedr RDMA/qedr: Fix incorrect device rate. 2020-01-27 14:50:50 +01:00
qib IB/hfi1, qib: Ensure RCU is locked when accessing list 2020-03-11 14:15:11 +01:00
usnic IB/usnic: Fix out of bounds index check in query pkey 2020-01-27 14:50:11 +01:00
vmw_pvrdma RDMA/vmw_pvrdma: Use atomic memory allocation in create AH 2019-12-05 09:20:01 +01:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00