[PATCH 1/6] Revert "mtd: blkdevs: fix potential deadlock + lockdep warnings"
From: Zhihao Cheng
Date: Sun Jun 13 2021 - 07:22:30 EST
This reverts commit f3c63795e90f0c6238306883b6c72f14d5355721.
---
drivers/mtd/mtd_blkdevs.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index fb8e12d590a1..16ccce3e7fdb 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -209,8 +209,8 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
if (!dev)
return -ERESTARTSYS; /* FIXME: busy loop! -arnd*/
- mutex_lock(&mtd_table_mutex);
mutex_lock(&dev->lock);
+ mutex_lock(&mtd_table_mutex);
if (dev->open)
goto unlock;
@@ -234,8 +234,8 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
unlock:
dev->open++;
- mutex_unlock(&dev->lock);
mutex_unlock(&mtd_table_mutex);
+ mutex_unlock(&dev->lock);
blktrans_dev_put(dev);
return ret;
@@ -245,8 +245,8 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
error_put:
module_put(dev->tr->owner);
kref_put(&dev->ref, blktrans_dev_release);
- mutex_unlock(&dev->lock);
mutex_unlock(&mtd_table_mutex);
+ mutex_unlock(&dev->lock);
blktrans_dev_put(dev);
return ret;
}
@@ -258,8 +258,8 @@ static void blktrans_release(struct gendisk *disk, fmode_t mode)
if (!dev)
return;
- mutex_lock(&mtd_table_mutex);
mutex_lock(&dev->lock);
+ mutex_lock(&mtd_table_mutex);
if (--dev->open)
goto unlock;
@@ -273,8 +273,8 @@ static void blktrans_release(struct gendisk *disk, fmode_t mode)
__put_mtd_device(dev->mtd);
}
unlock:
- mutex_unlock(&dev->lock);
mutex_unlock(&mtd_table_mutex);
+ mutex_unlock(&dev->lock);
blktrans_dev_put(dev);
}
--
2.31.1