From e981f7d67468937eff60db07c5097e41f9d8d205 Mon Sep 17 00:00:00 2001 From: Guanjun Date: Fri, 5 Aug 2022 14:58:57 +0800 Subject: [PATCH] anolis: crypto/ycc: fix unexpected logic when devices probing ANBZ: #1832 The order of YCC devices probing is unpredictable. Assume that: RCIEP 0 -> RCIEP 1 -> RCEC 0 -> RCEC 1, then we will encounter issue when probing RCIEP 1. And the stacks will like as follows: kernel: kernfs: can not remove 'ycc_rciep', no directory kernel: WARNING: CPU: 64 PID: 730 at fs/kernfs/dir.c:1576 kernfs_remove_by_name_ns+0xb4/0xc0 kernel: CPU: 64 PID: 730 Comm: kworker/64:1 Kdump: loaded Tainted: G W OE 5.19.0-ycc-for-upstream+ #1 kernel: Hardware name: T-Head To be filled by O.E.M./To be filled by O.E.M., BIOS M1CRB.RFB.01.019 2022-06-06 kernel: Workqueue: events work_for_cpu_fn kernel: pstate: 62401009 (nZCv daif +PAN -UAO +TCO -DIT +SSBS BTYPE=--) kernel: pc : kernfs_remove_by_name_ns+0xb4/0xc0 kernel: lr : kernfs_remove_by_name_ns+0xb4/0xc0 kernel: sp : ffff80001d363c90 kernel: x29: ffff80001d363c90 x28: 0000000000000000 x27: 0000000000000000 kernel: x26: ffff0400065a0174 x25: ffff8000011a9168 x24: ffff8000011ac480 kernel: x23: ffff8000011a9958 x22: ffff040008be2000 x21: ffff8000011a9948 kernel: x20: 0000000000000000 x19: ffff0400063cb400 x18: 0000000000000030 kernel: x17: 00000000f0db07a0 x16: ffff8000099ab780 x15: ffff040007a9a500 kernel: x14: ffffffffffffffff x13: 79726f7463657269 x12: 64206f6e202c2770 kernel: x11: 00000000ffff7fff x10: 00000000ffff7fff x9 : ffff8000080d48f8 kernel: x8 : 00000000000bffe8 x7 : c0000000ffff7fff x6 : 000000000005fff4 kernel: x5 : 00000000002bffa8 x4 : ffff80001d363ae0 x3 : ffff8426d64ed000 kernel: x2 : ffff0426df701c18 x1 : 0000000000000000 x0 : 0000000000000000 kernel: Call trace: kernel: kernfs_remove_by_name_ns+0xb4/0xc0 kernel: sysfs_remove_link+0x20/0x40 kernel: ycc_rcec_bind+0xac/0x220 [ycc] kernel: ycc_drv_probe+0xc4/0x490 [ycc] kernel: local_pci_probe+0x44/0xb0 kernel: work_for_cpu_fn+0x20/0x30 kernel: process_one_work+0x1f0/0x460 kernel: worker_thread+0x238/0x3d4 kernel: kthread+0xcc/0xd0 kernel: ret_from_fork+0x10/0x20 This patch aims to fix this issue. Signed-off-by: Guanjun Link: https://gitee.com/anolis/cloud-kernel/pulls/606 Reviewed-by: Zelin Deng --- drivers/crypto/ycc/ycc_drv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/crypto/ycc/ycc_drv.c b/drivers/crypto/ycc/ycc_drv.c index 83b88306d2b9..8765077f22c5 100644 --- a/drivers/crypto/ycc/ycc_drv.c +++ b/drivers/crypto/ycc/ycc_drv.c @@ -320,6 +320,8 @@ static int ycc_rcec_bind(struct ycc_dev *ydev) goto out; } + return ret; + remove_rcec_link: sysfs_remove_link(&rciep->pdev->dev.kobj, "ycc_rcec"); remove_rciep_link: -- Gitee