]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/scsi-libsas-delete-sas-port-if-expander-discover-fai.patch
Linux 5.1.13
[thirdparty/kernel/stable-queue.git] / queue-4.19 / scsi-libsas-delete-sas-port-if-expander-discover-fai.patch
1 From 93aafccd3def3d57a44dd3352d9c895b1b8178e0 Mon Sep 17 00:00:00 2001
2 From: Jason Yan <yanaijie@huawei.com>
3 Date: Tue, 14 May 2019 10:42:39 +0800
4 Subject: scsi: libsas: delete sas port if expander discover failed
5
6 [ Upstream commit 3b0541791453fbe7f42867e310e0c9eb6295364d ]
7
8 The sas_port(phy->port) allocated in sas_ex_discover_expander() will not be
9 deleted when the expander failed to discover. This will cause resource leak
10 and a further issue of kernel BUG like below:
11
12 [159785.843156] port-2:17:29: trying to add phy phy-2:17:29 fails: it's
13 already part of another port
14 [159785.852144] ------------[ cut here ]------------
15 [159785.856833] kernel BUG at drivers/scsi/scsi_transport_sas.c:1086!
16 [159785.863000] Internal error: Oops - BUG: 0 [#1] SMP
17 [159785.867866] CPU: 39 PID: 16993 Comm: kworker/u96:2 Tainted: G
18 W OE 4.19.25-vhulk1901.1.0.h111.aarch64 #1
19 [159785.878458] Hardware name: Huawei Technologies Co., Ltd.
20 Hi1620EVBCS/Hi1620EVBCS, BIOS Hi1620 CS B070 1P TA 03/21/2019
21 [159785.889231] Workqueue: 0000:74:02.0_disco_q sas_discover_domain
22 [159785.895224] pstate: 40c00009 (nZcv daif +PAN +UAO)
23 [159785.900094] pc : sas_port_add_phy+0x188/0x1b8
24 [159785.904524] lr : sas_port_add_phy+0x188/0x1b8
25 [159785.908952] sp : ffff0001120e3b80
26 [159785.912341] x29: ffff0001120e3b80 x28: 0000000000000000
27 [159785.917727] x27: ffff802ade8f5400 x26: ffff0000681b7560
28 [159785.923111] x25: ffff802adf11a800 x24: ffff0000680e8000
29 [159785.928496] x23: ffff802ade8f5728 x22: ffff802ade8f5708
30 [159785.933880] x21: ffff802adea2db40 x20: ffff802ade8f5400
31 [159785.939264] x19: ffff802adea2d800 x18: 0000000000000010
32 [159785.944649] x17: 00000000821bf734 x16: ffff00006714faa0
33 [159785.950033] x15: ffff0000e8ab4ecf x14: 7261702079646165
34 [159785.955417] x13: 726c612073277469 x12: ffff00006887b830
35 [159785.960802] x11: ffff00006773eaa0 x10: 7968702079687020
36 [159785.966186] x9 : 0000000000002453 x8 : 726f702072656874
37 [159785.971570] x7 : 6f6e6120666f2074 x6 : ffff802bcfb21290
38 [159785.976955] x5 : ffff802bcfb21290 x4 : 0000000000000000
39 [159785.982339] x3 : ffff802bcfb298c8 x2 : 337752b234c2ab00
40 [159785.987723] x1 : 337752b234c2ab00 x0 : 0000000000000000
41 [159785.993108] Process kworker/u96:2 (pid: 16993, stack limit =
42 0x0000000072dae094)
43 [159786.000576] Call trace:
44 [159786.003097] sas_port_add_phy+0x188/0x1b8
45 [159786.007179] sas_ex_get_linkrate.isra.5+0x134/0x140
46 [159786.012130] sas_ex_discover_expander+0x128/0x408
47 [159786.016906] sas_ex_discover_dev+0x218/0x4c8
48 [159786.021249] sas_ex_discover_devices+0x9c/0x1a8
49 [159786.025852] sas_discover_root_expander+0x134/0x160
50 [159786.030802] sas_discover_domain+0x1b8/0x1e8
51 [159786.035148] process_one_work+0x1b4/0x3f8
52 [159786.039230] worker_thread+0x54/0x470
53 [159786.042967] kthread+0x134/0x138
54 [159786.046269] ret_from_fork+0x10/0x18
55 [159786.049918] Code: 91322300 f0004402 91178042 97fe4c9b (d4210000)
56 [159786.056083] Modules linked in: hns3_enet_ut(OE) hclge(OE) hnae3(OE)
57 hisi_sas_test_hw(OE) hisi_sas_test_main(OE) serdes(OE)
58 [159786.067202] ---[ end trace 03622b9e2d99e196 ]---
59 [159786.071893] Kernel panic - not syncing: Fatal exception
60 [159786.077190] SMP: stopping secondary CPUs
61 [159786.081192] Kernel Offset: disabled
62 [159786.084753] CPU features: 0x2,a2a00a38
63
64 Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver")
65 Reported-by: Jian Luo <luojian5@huawei.com>
66 Signed-off-by: Jason Yan <yanaijie@huawei.com>
67 CC: John Garry <john.garry@huawei.com>
68 Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
69 Signed-off-by: Sasha Levin <sashal@kernel.org>
70 ---
71 drivers/scsi/libsas/sas_expander.c | 2 ++
72 1 file changed, 2 insertions(+)
73
74 diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
75 index 231eb79efa32..b141d1061f38 100644
76 --- a/drivers/scsi/libsas/sas_expander.c
77 +++ b/drivers/scsi/libsas/sas_expander.c
78 @@ -989,6 +989,8 @@ static struct domain_device *sas_ex_discover_expander(
79 list_del(&child->dev_list_node);
80 spin_unlock_irq(&parent->port->dev_list_lock);
81 sas_put_device(child);
82 + sas_port_delete(phy->port);
83 + phy->port = NULL;
84 return NULL;
85 }
86 list_add_tail(&child->siblings, &parent->ex_dev.children);
87 --
88 2.20.1
89