Commit e96a8a3b authored by shengyong's avatar shengyong Committed by Richard Weinberger

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: default avatarSheng Yong <shengyong1@huawei.com>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent e8d266cf
...@@ -192,8 +192,10 @@ static struct ubi_ainf_volume *add_vol(struct ubi_attach_info *ai, int vol_id, ...@@ -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) if (vol_id > av->vol_id)
p = &(*p)->rb_left; p = &(*p)->rb_left;
else else if (vol_id < av->vol_id)
p = &(*p)->rb_right; p = &(*p)->rb_right;
else
return ERR_PTR(-EINVAL);
} }
av = kmalloc(sizeof(struct ubi_ainf_volume), GFP_KERNEL); av = kmalloc(sizeof(struct ubi_ainf_volume), GFP_KERNEL);
...@@ -748,6 +750,11 @@ static int ubi_attach_fastmap(struct ubi_device *ubi, ...@@ -748,6 +750,11 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
if (!av) if (!av)
goto fail_bad; 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++; ai->vols_found++;
if (ai->highest_vol_id < be32_to_cpu(fmvhdr->vol_id)) if (ai->highest_vol_id < be32_to_cpu(fmvhdr->vol_id))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment