Skip to content

Commit 40b6e61

Browse files
Boris Brezillonrichardweinberger
authored andcommitted
ubi: fastmap: Fix add_vol() return value test in ubi_attach_fastmap()
Commit e96a8a3 ("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: e96a8a3 ("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>
1 parent 14970f2 commit 40b6e61

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/mtd/ubi/fastmap.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -707,11 +707,11 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
707707
fmvhdr->vol_type,
708708
be32_to_cpu(fmvhdr->last_eb_bytes));
709709

710-
if (!av)
711-
goto fail_bad;
712-
if (PTR_ERR(av) == -EINVAL) {
713-
ubi_err(ubi, "volume (ID %i) already exists",
714-
fmvhdr->vol_id);
710+
if (IS_ERR(av)) {
711+
if (PTR_ERR(av) == -EEXIST)
712+
ubi_err(ubi, "volume (ID %i) already exists",
713+
fmvhdr->vol_id);
714+
715715
goto fail_bad;
716716
}
717717

0 commit comments

Comments
 (0)