diff options
author | shengyong | 2015-05-26 10:07:09 +0000 |
---|---|---|
committer | Richard Weinberger | 2015-06-02 11:46:14 +0200 |
commit | e96a8a3bb671ca02370e85993c3f50ee90691b95 (patch) | |
tree | 8ee2566efd1050a349951651fb05b95a62b94382 | |
parent | e8d266cf8d24e52eac65bdab24afd6f4cfc0ad07 (diff) |
UBI: Fastmap: Do not add vol if it already exists
During fastmap attaching, check if a volume already exists when adding
the volume to volume tree. NOTE that the issue cannot happen, only if
the on-flash fastmap data is modified.
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
-rw-r--r-- | drivers/mtd/ubi/fastmap.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c index e3d829409fa6..9eee9044b11f 100644 --- a/drivers/mtd/ubi/fastmap.c +++ b/drivers/mtd/ubi/fastmap.c @@ -192,8 +192,10 @@ static struct ubi_ainf_volume *add_vol(struct ubi_attach_info *ai, int vol_id, if (vol_id > av->vol_id) p = &(*p)->rb_left; - else + else if (vol_id < av->vol_id) p = &(*p)->rb_right; + else + return ERR_PTR(-EINVAL); } av = kmalloc(sizeof(struct ubi_ainf_volume), GFP_KERNEL); @@ -748,6 +750,11 @@ static int ubi_attach_fastmap(struct ubi_device *ubi, if (!av) goto fail_bad; + if (PTR_ERR(av) == -EINVAL) { + ubi_err(ubi, "volume (ID %i) already exists", + fmvhdr->vol_id); + goto fail_bad; + } ai->vols_found++; if (ai->highest_vol_id < be32_to_cpu(fmvhdr->vol_id)) |