mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "open list:BAREBOX" <barebox@lists.infradead.org>
Subject: [PATCH 1/4] fs: open loopback device before using it
Date: Thu, 07 Nov 2024 08:23:30 +0100	[thread overview]
Message-ID: <20241107-fs-tftp-v1-1-39d7e1cff418@pengutronix.de> (raw)
In-Reply-To: <20241107-fs-tftp-v1-0-39d7e1cff418@pengutronix.de>

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@pengutronix.de>
---
 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




  reply	other threads:[~2024-11-07  8:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07  7:23 [PATCH 0/4] some fs/tftp updates Sascha Hauer
2024-11-07  7:23 ` Sascha Hauer [this message]
2024-11-07  7:23 ` [PATCH 2/4] fs: tftp: cache dentries for some time Sascha Hauer
2024-11-07  7:23 ` [PATCH 3/4] fs: kill invalid dentries Sascha Hauer
2024-11-07  7:23 ` [PATCH 4/4] fs: tftp: Set default window size to 1 Sascha Hauer
2024-11-08 13:26 ` [PATCH 0/4] some fs/tftp updates Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241107-fs-tftp-v1-1-39d7e1cff418@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox