[PATCH 4/6] Revert "mtd: mtd_blkdevs: fix error path in blktrans_open"

Zhihao Cheng chengzhihao1 at huawei.com
Sun Jun 13 04:30:33 PDT 2021


This reverts commit 94735ec4044a6d318b83ad3c5794e931ed168d10.
---
 drivers/mtd/mtd_blkdevs.c | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 100a3c96760c..41dd3b955136 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -217,34 +217,17 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
 	kref_get(&dev->ref);
 	__module_get(dev->tr->owner);
 
-	if (!dev->mtd)
-		goto unlock;
-
-	if (dev->tr->open) {
-		ret = dev->tr->open(dev);
-		if (ret)
-			goto error_put;
+	if (dev->mtd) {
+		ret = dev->tr->open ? dev->tr->open(dev) : 0;
+		__get_mtd_device(dev->mtd);
 	}
 
-	ret = __get_mtd_device(dev->mtd);
-	if (ret)
-		goto error_release;
 	dev->file_mode = mode;
 
 unlock:
 	mutex_unlock(&dev->lock);
 	blktrans_dev_put(dev);
 	return ret;
-
-error_release:
-	if (dev->tr->release)
-		dev->tr->release(dev);
-error_put:
-	module_put(dev->tr->owner);
-	kref_put(&dev->ref, blktrans_dev_release);
-	mutex_unlock(&dev->lock);
-	blktrans_dev_put(dev);
-	return ret;
 }
 
 static void blktrans_release(struct gendisk *disk, fmode_t mode)
-- 
2.31.1




More information about the linux-mtd mailing list