mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Cc: Steffen Trumtrar <str@pengutronix.de>
Subject: [PATCH 3/3] devfs: check for valid flags before removing a partition
Date: Thu, 12 Oct 2023 13:10:44 +0200	[thread overview]
Message-ID: <20231012111044.406987-3-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20231012111044.406987-1-s.hauer@pengutronix.de>

When a partition is a mtd device then it is removed before checking if
the cdev actually a partition. move the call to mtd_del_partition()
further down to a point where we know the operation is valid.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/devfs-core.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index c9f7fcfb07..4e16d55e36 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -582,16 +582,16 @@ int devfs_del_partition(const char *name)
 	if (!cdev)
 		return -ENOENT;
 
-	if (IS_ENABLED(CONFIG_MTD) && cdev->mtd) {
-		ret = mtd_del_partition(cdev->mtd);
-		return ret;
-	}
-
 	if (!cdev_is_partition(cdev))
 		return -EINVAL;
 	if (cdev->flags & DEVFS_PARTITION_FIXED)
 		return -EPERM;
 
+	if (IS_ENABLED(CONFIG_MTD) && cdev->mtd) {
+		ret = mtd_del_partition(cdev->mtd);
+		return ret;
+	}
+
 	ret = devfs_remove(cdev);
 	if (ret)
 		return ret;
-- 
2.39.2




      parent reply	other threads:[~2023-10-12 11:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12 11:10 [PATCH 1/3] mtd: initialize partitions_entry Sascha Hauer
2023-10-12 11:10 ` [PATCH 2/3] bootstrap: Fix partition creation Sascha Hauer
2023-10-12 11:47   ` Steffen Trumtrar
2023-10-12 13:36     ` Sascha Hauer
2023-10-12 11:10 ` Sascha Hauer [this message]

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=20231012111044.406987-3-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=str@pengutronix.de \
    /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