Yang Shi
d21f3eaa09
locktorture: Fix potential memory leak with rw lock test
commit f4dbba591945dc301c302672adefba9e2ec08dc5 upstream.
When running locktorture module with the below commands with kmemleak enabled:
$ modprobe locktorture torture_type=rw_lock_irq
$ rmmod locktorture
The below kmemleak got caught:
root@10:~# echo scan > /sys/kernel/debug/kmemleak
[ 323.197029] kmemleak: 2 new suspected memory leaks (see /sys/kernel/debug/kmemleak)
root@10:~# cat /sys/kernel/debug/kmemleak
unreferenced object 0xffffffc07592d500 (size 128):
comm "modprobe", pid 368, jiffies 4294924118 (age 205.824s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 c3 7b 02 00 00 00 00 00 .........{......
00 00 00 00 00 00 00 00 d7 9b 02 00 00 00 00 00 ................
backtrace:
[<ffffff80081e5a88>] create_object+0x110/0x288
[<ffffff80086c6078>] kmemleak_alloc+0x58/0xa0
[<ffffff80081d5acc>] __kmalloc+0x234/0x318
[<ffffff80006fa130>] 0xffffff80006fa130
[<ffffff8008083ae4>] do_one_initcall+0x44/0x138
[<ffffff800817e28c>] do_init_module+0x68/0x1cc
[<ffffff800811c848>] load_module+0x1a68/0x22e0
[<ffffff800811d340>] SyS_finit_module+0xe0/0xf0
[<ffffff80080836f0>] el0_svc_naked+0x24/0x28
[<ffffffffffffffff>] 0xffffffffffffffff
unreferenced object 0xffffffc07592d480 (size 128):
comm "modprobe", pid 368, jiffies 4294924118 (age 205.824s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 3b 6f 01 00 00 00 00 00 ........;o......
00 00 00 00 00 00 00 00 23 6a 01 00 00 00 00 00 ........#j......
backtrace:
[<ffffff80081e5a88>] create_object+0x110/0x288
[<ffffff80086c6078>] kmemleak_alloc+0x58/0xa0
[<ffffff80081d5acc>] __kmalloc+0x234/0x318
[<ffffff80006fa22c>] 0xffffff80006fa22c
[<ffffff8008083ae4>] do_one_initcall+0x44/0x138
[<ffffff800817e28c>] do_init_module+0x68/0x1cc
[<ffffff800811c848>] load_module+0x1a68/0x22e0
[<ffffff800811d340>] SyS_finit_module+0xe0/0xf0
[<ffffff80080836f0>] el0_svc_naked+0x24/0x28
[<ffffffffffffffff>] 0xffffffffffffffff
It is because cxt.lwsa and cxt.lrsa don't get freed in module_exit, so free
them in lock_torture_cleanup() and free writer_tasks if reader_tasks is
failed at memory allocation.
Signed-off-by: Yang Shi <yang.shi@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Cc: 石洋 <yang.s@alibaba-inc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
2017-09-13 14:13:36 -07:00 |
| .. |
|
lockdep.c
|
lockdep: Fix report formatting
|
2016-12-06 10:40:08 +01:00 |
|
lockdep_internals.h
|
lockdep: Limit static allocations if PROVE_LOCKING_SMALL is defined
|
2016-11-18 11:33:19 -08:00 |
|
lockdep_proc.c
|
lockdep: Fix lock_chain::base size
|
2016-04-23 13:53:03 +02:00 |
|
lockdep_states.h
|
|
|
|
locktorture.c
|
locktorture: Fix potential memory leak with rw lock test
|
2017-09-13 14:13:36 -07:00 |
|
Makefile
|
locking/lglock: Remove lglock implementation
|
2016-09-22 15:25:56 +02:00 |
|
mcs_spinlock.h
|
locking/mcs: Fix mcs_spin_lock() ordering
|
2016-02-29 10:02:41 +01:00 |
|
mutex-debug.c
|
locking: avoid passing around 'thread_info' in mutex debugging code
|
2016-06-23 12:11:17 -07:00 |
|
mutex-debug.h
|
Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
|
2016-07-25 12:41:29 -07:00 |
|
mutex.c
|
locking: avoid passing around 'thread_info' in mutex debugging code
|
2016-06-23 12:11:17 -07:00 |
|
mutex.h
|
Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
|
2016-07-25 12:41:29 -07:00 |
|
osq_lock.c
|
locking/osq: Fix ordering of node initialisation in osq_lock
|
2015-12-17 11:40:29 -08:00 |
|
percpu-rwsem.c
|
locking/percpu-rwsem: Optimize readers and reduce global impact
|
2016-08-10 14:34:01 +02:00 |
|
qrwlock.c
|
locking/atomic, arch/qrwlock: Employ atomic_fetch_add_acquire()
|
2016-06-16 10:48:34 +02:00 |
|
qspinlock.c
|
locking/qspinlock: Use __this_cpu_dec() instead of full-blown this_cpu_dec()
|
2016-06-27 11:37:41 +02:00 |
|
qspinlock_paravirt.h
|
locking/pv-qspinlock: Use cmpxchg_release() in __pv_queued_spin_unlock()
|
2016-09-22 15:25:51 +02:00 |
|
qspinlock_stat.h
|
locking/pvstat: Separate wait_again and spurious wakeup stats
|
2016-08-10 14:16:02 +02:00 |
|
rtmutex-debug.c
|
rtmutex: Cleanup deadlock detector debug logic
|
2014-06-21 22:05:30 +02:00 |
|
rtmutex-debug.h
|
rtmutex: Cleanup deadlock detector debug logic
|
2014-06-21 22:05:30 +02:00 |
|
rtmutex.c
|
locking/rtmutex: Prevent dequeue vs. unlock race
|
2016-12-02 11:13:26 +01:00 |
|
rtmutex.h
|
rtmutex: Cleanup deadlock detector debug logic
|
2014-06-21 22:05:30 +02:00 |
|
rtmutex_common.h
|
locking/rtmutex: Use READ_ONCE() in rt_mutex_owner()
|
2016-12-02 11:13:26 +01:00 |
|
rwsem-spinlock.c
|
locking/rwsem-spinlock: Fix EINTR branch in __down_write_common()
|
2017-07-15 12:16:15 +02:00 |
|
rwsem-xadd.c
|
locking/rwsem: Scan the wait_list for readers only once
|
2016-08-18 15:37:11 +02:00 |
|
rwsem.c
|
locking/rwsem: Add reader-owned state to the owner field
|
2016-06-08 15:16:59 +02:00 |
|
rwsem.h
|
locking/rwsem: Protect all writes to owner by WRITE_ONCE()
|
2016-06-08 15:16:59 +02:00 |
|
semaphore.c
|
locking/semaphore: Resolve some shadow warnings
|
2014-09-04 07:17:24 +02:00 |
|
spinlock.c
|
spinlock: Add spin_lock_bh_nested()
|
2015-01-03 14:32:57 -05:00 |
|
spinlock_debug.c
|
locking/spinlock/debug: Remove spinlock lockup detection code
|
2017-09-02 07:07:54 +02:00 |