Yang Shi
d21f3eaa09
locktorture: Fix potential memory leak with rw lock test
commit f4dbba5919 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
..
2017-08-30 10:21:44 +02:00
2016-10-11 15:06:32 -07:00
2017-01-06 10:40:17 +01:00
2017-09-07 08:35:39 +02:00
2017-09-02 07:07:53 +02:00
2017-08-24 17:12:21 -07:00
2016-08-26 14:42:08 +02:00
2017-09-13 14:13:36 -07:00
2016-11-02 05:10:04 +01:00
2017-02-23 17:44:36 +01:00
2017-07-21 07:42:22 +02:00
2017-08-06 18:59:42 -07:00
2017-08-30 10:21:51 +02:00
2017-08-30 10:21:50 +02:00
2015-10-21 15:18:35 +01:00
2015-04-11 22:27:55 -04:00
2015-11-19 17:51:48 +01:00
2016-01-22 18:04:28 -05:00
2016-04-04 09:46:47 -04:00
2017-08-24 17:12:18 -07:00
2016-10-04 14:21:41 -07:00
2016-07-29 17:54:17 -07:00
2016-06-27 11:01:00 -04:00
2016-10-04 14:21:41 -07:00
2014-06-04 16:54:14 -07:00
2014-08-08 15:57:18 -07:00
2017-01-06 10:40:13 +01:00
2015-12-03 10:24:08 -05:00
2017-03-26 13:05:58 +02:00
2017-08-11 08:49:28 -07:00
2015-06-04 23:57:18 +02:00
2015-11-24 09:56:43 +01:00
2015-09-03 02:42:20 +02:00
2017-08-06 18:59:41 -07:00
2017-09-07 08:35:40 +02:00
2014-08-25 15:42:19 -07:00
2016-06-30 18:05:09 -05:00
2016-01-14 16:00:49 -08:00
2015-04-12 21:03:31 +02:00
2016-11-22 12:33:43 +01:00
2017-07-21 07:42:21 +02:00
2017-09-07 08:35:39 +02:00
2016-07-28 16:07:41 -07:00
2016-01-20 17:09:18 -08:00
2017-08-16 13:43:15 -07:00
2016-10-07 18:46:30 -07:00
2016-10-11 15:06:33 -07:00
2015-11-23 09:44:58 +01:00
2017-01-19 20:17:59 +01:00
2016-03-15 16:55:16 -07:00
2016-01-20 17:09:18 -08:00
2015-05-12 09:46:00 +02:00
2016-12-07 17:10:00 -08:00
2016-08-02 19:35:31 -04:00
2016-09-01 17:52:01 -07:00
2016-01-20 17:09:18 -08:00
2016-08-02 19:35:27 -04:00
2015-10-23 17:55:10 +09:00
2017-05-25 15:44:47 +02:00
2016-08-02 19:35:30 -04:00
2017-04-21 09:31:18 +02:00
2016-02-09 11:54:23 +01:00
2017-06-17 06:41:57 +02:00
2017-03-12 06:41:45 +01:00
2017-03-12 06:41:43 +01:00
2016-04-11 22:43:43 +01:00
2016-11-29 16:01:30 -08:00
2015-09-01 08:40:25 -07:00
2016-02-16 13:04:58 -05:00
2017-05-20 14:28:40 +02:00
2017-07-05 14:40:24 +02:00
2015-11-09 15:53:39 -08:00
2017-05-25 15:44:38 +02:00
2017-08-24 17:12:21 -07:00
2016-07-15 10:41:42 +02:00
2017-06-14 15:05:54 +02:00
2015-01-17 10:02:23 +13:00
2015-09-10 13:29:01 -07:00
2017-01-12 11:39:30 +01:00
2016-04-14 12:56:09 -07:00
2016-08-30 16:12:46 -07:00
2017-08-11 08:49:36 -07:00
2016-09-22 14:49:10 +02:00
2016-10-11 15:06:33 -07:00
2016-03-01 20:36:56 +01:00
2016-10-21 15:45:47 -06:00
2017-02-14 15:25:42 -08:00
2016-10-03 13:39:00 -07:00
2016-09-13 14:41:36 +02:00
2016-05-23 17:04:14 -07:00
2016-05-20 17:58:30 -07:00
2017-07-12 15:01:04 +02:00
2016-08-02 19:35:02 -04:00
2016-11-03 16:55:58 -04:00
2014-08-08 15:57:18 -07:00
2016-08-22 10:01:49 -07:00
2016-03-22 15:36:02 -07:00
2016-02-29 09:53:09 +01:00
2017-06-17 06:41:51 +02:00
2016-10-07 18:46:30 -07:00
2016-09-05 13:52:39 +02:00
2016-09-22 20:00:36 -05:00
2014-08-26 13:45:45 -04:00
2014-12-17 12:31:40 -08:00
2014-06-06 16:08:16 -07:00
2016-09-22 20:00:36 -05:00
2017-06-17 06:41:57 +02:00
2017-06-17 06:41:57 +02:00
2016-03-02 10:28:47 -05:00
2017-08-11 08:49:37 -07:00