Patchwork [04/21] UBI: Fastmap: Check for duplicated PEBs in add_aeb()

login
register
mail settings
Submitter Richard Weinberger
Date June 13, 2012, 10:42 a.m.
Message ID <1339584138-69914-5-git-send-email-richard@nod.at>
Download mbox | patch
Permalink /patch/164617/
State New
Headers show

Comments

Richard Weinberger - June 13, 2012, 10:42 a.m.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
 drivers/mtd/ubi/fastmap.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Patch

diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index d446fc3..97d694f 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -53,6 +53,10 @@  static int add_aeb(struct ubi_attach_info *ai, struct list_head *list,
 {
 	struct ubi_ainf_peb *aeb;
 
+	list_for_each_entry(aeb, list, u.list)
+		if (aeb->pnum == pnum)
+			return 0;
+
 	aeb = kmem_cache_alloc(ai->aeb_slab_cache, GFP_KERNEL);
 	if (!aeb)
 		return -ENOMEM;