]> git.baikalelectronics.ru Git - kernel.git/commit
crypto: hisilicon/qm - fix deadlock for remove driver
authorYang Shen <shenyang39@huawei.com>
Sat, 11 Dec 2021 08:56:55 +0000 (16:56 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 17 Dec 2021 05:59:48 +0000 (16:59 +1100)
commit0a2dd06ce7fc16e78a74b12ebc6d7e88af0435f7
tree9d870be6ee65ec56e6a7ddb09efdc570f16baf0f
parent023c7befdf000a79a16db2d15daf5560b56036ec
crypto: hisilicon/qm - fix deadlock for remove driver

When remove the driver and executing the task occur at the same time,
the following deadlock will be triggered:

Chain exists of:
    sva_lock --> uacce_mutex --> &qm->qps_lock
    Possible unsafe locking scenario:
CPU0                    CPU1
----                    ----
lock(&qm->qps_lock);
lock(uacce_mutex);
lock(&qm->qps_lock);
lock(sva_lock);

And the lock 'qps_lock' is used to protect qp. Therefore, it's reasonable
cycle is to continue until the qp memory is released. So move the release
lock infront of 'uacce_remove'.

Signed-off-by: Yang Shen <shenyang39@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/hisilicon/qm.c