]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.11.2/dm-thin-fix-a-memory-leak-when-passing-discard-bio-down.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.11.2 / dm-thin-fix-a-memory-leak-when-passing-discard-bio-down.patch
CommitLineData
b889272d
GKH
1From 948f581a53b704b984aa20df009f0a2b4cf7f907 Mon Sep 17 00:00:00 2001
2From: Dennis Yang <dennisyang@qnap.com>
3Date: Tue, 18 Apr 2017 15:27:06 +0800
4Subject: dm thin: fix a memory leak when passing discard bio down
5
6From: Dennis Yang <dennisyang@qnap.com>
7
8commit 948f581a53b704b984aa20df009f0a2b4cf7f907 upstream.
9
10dm-thin does not free the discard_parent bio after all chained sub
11bios finished. The following kmemleak report could be observed after
12pool with discard_passdown option processes discard bios in
13linux v4.11-rc7. To fix this, we drop the discard_parent bio reference
14when its endio (passdown_endio) called.
15
16unreferenced object 0xffff8803d6b29700 (size 256):
17 comm "kworker/u8:0", pid 30349, jiffies 4379504020 (age 143002.776s)
18 hex dump (first 32 bytes):
19 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
20 01 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 00 ................
21 backtrace:
22 [<ffffffff81a5efd9>] kmemleak_alloc+0x49/0xa0
23 [<ffffffff8114ec34>] kmem_cache_alloc+0xb4/0x100
24 [<ffffffff8110eec0>] mempool_alloc_slab+0x10/0x20
25 [<ffffffff8110efa5>] mempool_alloc+0x55/0x150
26 [<ffffffff81374939>] bio_alloc_bioset+0xb9/0x260
27 [<ffffffffa018fd20>] process_prepared_discard_passdown_pt1+0x40/0x1c0 [dm_thin_pool]
28 [<ffffffffa018b409>] break_up_discard_bio+0x1a9/0x200 [dm_thin_pool]
29 [<ffffffffa018b484>] process_discard_cell_passdown+0x24/0x40 [dm_thin_pool]
30 [<ffffffffa018b24d>] process_discard_bio+0xdd/0xf0 [dm_thin_pool]
31 [<ffffffffa018ecf6>] do_worker+0xa76/0xd50 [dm_thin_pool]
32 [<ffffffff81086239>] process_one_work+0x139/0x370
33 [<ffffffff810867b1>] worker_thread+0x61/0x450
34 [<ffffffff8108b316>] kthread+0xd6/0xf0
35 [<ffffffff81a6cd1f>] ret_from_fork+0x3f/0x70
36 [<ffffffffffffffff>] 0xffffffffffffffff
37
38Signed-off-by: Dennis Yang <dennisyang@qnap.com>
39Signed-off-by: Mike Snitzer <snitzer@redhat.com>
40Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
41
42---
43 drivers/md/dm-thin.c | 1 +
44 1 file changed, 1 insertion(+)
45
46--- a/drivers/md/dm-thin.c
47+++ b/drivers/md/dm-thin.c
48@@ -1069,6 +1069,7 @@ static void passdown_endio(struct bio *b
49 * to unmap (we ignore err).
50 */
51 queue_passdown_pt2(bio->bi_private);
52+ bio_put(bio);
53 }
54
55 static void process_prepared_discard_passdown_pt1(struct dm_thin_new_mapping *m)