mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-24 09:13:20 -05:00
net: ethernet: mtk_wed: fix possible deadlock if mtk_wed_wo_init fails
Introduce __mtk_wed_detach() in order to avoid a deadlock in
mtk_wed_attach routine if mtk_wed_wo_init fails since both
mtk_wed_attach and mtk_wed_detach run holding hw_lock mutex.
Fixes: 4c5de09eb0
("net: ethernet: mtk_wed: add configure wed wo support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
c79e0af5ae
commit
587585e1bb
1 changed files with 12 additions and 5 deletions
|
@ -577,12 +577,10 @@ mtk_wed_deinit(struct mtk_wed_device *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mtk_wed_detach(struct mtk_wed_device *dev)
|
__mtk_wed_detach(struct mtk_wed_device *dev)
|
||||||
{
|
{
|
||||||
struct mtk_wed_hw *hw = dev->hw;
|
struct mtk_wed_hw *hw = dev->hw;
|
||||||
|
|
||||||
mutex_lock(&hw_lock);
|
|
||||||
|
|
||||||
mtk_wed_deinit(dev);
|
mtk_wed_deinit(dev);
|
||||||
|
|
||||||
mtk_wdma_rx_reset(dev);
|
mtk_wdma_rx_reset(dev);
|
||||||
|
@ -615,6 +613,13 @@ mtk_wed_detach(struct mtk_wed_device *dev)
|
||||||
module_put(THIS_MODULE);
|
module_put(THIS_MODULE);
|
||||||
|
|
||||||
hw->wed_dev = NULL;
|
hw->wed_dev = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mtk_wed_detach(struct mtk_wed_device *dev)
|
||||||
|
{
|
||||||
|
mutex_lock(&hw_lock);
|
||||||
|
__mtk_wed_detach(dev);
|
||||||
mutex_unlock(&hw_lock);
|
mutex_unlock(&hw_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1497,8 +1502,10 @@ mtk_wed_attach(struct mtk_wed_device *dev)
|
||||||
ret = mtk_wed_wo_init(hw);
|
ret = mtk_wed_wo_init(hw);
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
if (ret)
|
if (ret) {
|
||||||
mtk_wed_detach(dev);
|
dev_err(dev->hw->dev, "failed to attach wed device\n");
|
||||||
|
__mtk_wed_detach(dev);
|
||||||
|
}
|
||||||
unlock:
|
unlock:
|
||||||
mutex_unlock(&hw_lock);
|
mutex_unlock(&hw_lock);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue