diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2020-04-16 08:18:28 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-04-30 11:30:13 +0200 |
commit | d9e5eb8ec4dfa70d2a3afb1a326da80ae82c06f0 (patch) | |
tree | 1b47e3cfd7a8c0304d843f2e0f6d7f58d98a9b16 /drivers/mtd | |
parent | 9a08b99d266f6ca94e2e2859eb752fedbd8d6bd7 (diff) | |
download | barebox-d9e5eb8ec4dfa70d2a3afb1a326da80ae82c06f0.tar.gz barebox-d9e5eb8ec4dfa70d2a3afb1a326da80ae82c06f0.tar.xz |
ubi: Refuse to attach partitioned mtd devices
When a mtd device has partitions it is wrong to attach the whole device
as this would corrupt the partitions. Refuse to attach it.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/ubi/build.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 604fe87e53..da409010f7 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -508,6 +508,14 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, struct ubi_device *ubi; int i, err, ref = 0; + /* + * Do not try to attach an UBI device if this device has partitions + * as it's not a good idea to attach UBI on a raw device when the + * real UBI only spans the first partition. + */ + if (!list_empty(&mtd->partitions)) + return -EBUSY; + if (max_beb_per1024 < 0 || max_beb_per1024 > MAX_MTD_UBI_BEB_LIMIT) return -EINVAL; |