[PATCH 3/3] devfs: check for valid flags before removing a partition

Sascha Hauer s.hauer at pengutronix.de
Thu Oct 12 04:10:44 PDT 2023


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 at 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




More information about the barebox mailing list