aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@free-electrons.com>2016-10-28 05:08:44 -0400
committerRichard Weinberger <richard@nod.at>2016-10-28 08:48:18 -0400
commit40b6e61ac72e99672e47cdb99c8d7d226004169b (patch)
tree5c645b21a18ac218b16e70a2f22e3ccd7354cc1b /drivers/mtd/ubi
parent14970f204b1993af7459d5bd34aaff38dfee6670 (diff)
ubi: fastmap: Fix add_vol() return value test in ubi_attach_fastmap()
Commit e96a8a3bb671 ("UBI: Fastmap: Do not add vol if it already exists") introduced a bug by changing the possible error codes returned by add_vol(): - this function no longer returns NULL in case of allocation failure but return ERR_PTR(-ENOMEM) - when a duplicate entry in the volume RB tree is found it returns ERR_PTR(-EEXIST) instead of ERR_PTR(-EINVAL) Fix the tests done on add_vol() return val to match this new behavior. Fixes: e96a8a3bb671 ("UBI: Fastmap: Do not add vol if it already exists") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Acked-by: Sheng Yong <shengyong1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'drivers/mtd/ubi')
-rw-r--r--drivers/mtd/ubi/fastmap.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index 2ff62157d3bb..c1f5c29e458e 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -707,11 +707,11 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
707 fmvhdr->vol_type, 707 fmvhdr->vol_type,
708 be32_to_cpu(fmvhdr->last_eb_bytes)); 708 be32_to_cpu(fmvhdr->last_eb_bytes));
709 709
710 if (!av) 710 if (IS_ERR(av)) {
711 goto fail_bad; 711 if (PTR_ERR(av) == -EEXIST)
712 if (PTR_ERR(av) == -EINVAL) { 712 ubi_err(ubi, "volume (ID %i) already exists",
713 ubi_err(ubi, "volume (ID %i) already exists", 713 fmvhdr->vol_id);
714 fmvhdr->vol_id); 714
715 goto fail_bad; 715 goto fail_bad;
716 } 716 }
717 717