[PATCH 1/4] fs: open loopback device before using it

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The loopback cdev created with cdev_create_loop() is used, but never
opened. Open it before usage.

Not having it opened has the effect that during unmount of a loopback
mounted file the devfs_remove() call for the loopback cdev fails,
because the usage counter drops below zero.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 fs/fs.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/fs.c b/fs/fs.c
index 5e7e05f499..f24962d2a6 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -933,6 +933,13 @@ int fsdev_open_cdev(struct fs_device *fsdev)
 			return ret;
 
 		fsdev->cdev = cdev_create_loop(fsdev->backingstore, O_RDWR, offset);
+		if (fsdev->cdev) {
+			ret = cdev_open(fsdev->cdev, O_RDWR);
+			if (ret) {
+				cdev_remove_loop(fsdev->cdev);
+				fsdev->cdev = NULL;
+			}
+		}
 	} else {
 		fsdev->cdev = cdev_open_by_name(fsdev->backingstore, O_RDWR);
 	}

-- 
2.39.5





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux