linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* UBI patches for 2.6.36
@ 2010-08-29 12:12 Artem Bityutskiy
  2010-08-29 12:13 ` [PATCH 1/2] UBI: eliminate update of list_for_each_entry loop cursor Artem Bityutskiy
  2010-08-29 12:14 ` [PATCH 2/2] UBI: fix forward compatibility Artem Bityutskiy
  0 siblings, 2 replies; 3+ messages in thread
From: Artem Bityutskiy @ 2010-08-29 12:12 UTC (permalink / raw)
  To: linux-mtd

Hi,

I'm going to send the following patches to Linus soonish, any
objections?

-- 
Best Regards,
Artem Bityutskiy (Битюцкий Артём)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] UBI: eliminate update of list_for_each_entry loop cursor
  2010-08-29 12:12 UBI patches for 2.6.36 Artem Bityutskiy
@ 2010-08-29 12:13 ` Artem Bityutskiy
  2010-08-29 12:14 ` [PATCH 2/2] UBI: fix forward compatibility Artem Bityutskiy
  1 sibling, 0 replies; 3+ messages in thread
From: Artem Bityutskiy @ 2010-08-29 12:13 UTC (permalink / raw)
  To: linux-mtd

From: Julia Lawall <julia@diku.dk>

list_for_each_entry uses its first argument to move from one element to the
next, so modifying it can break the iteration.  The variable re1 is already
used within the loop as a temporary variable, and is not live here.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r@
iterator name list_for_each_entry;
expression x,E;
position p1,p2;
@@

list_for_each_entry@p1(x,...) { <... x =@p2 E ...> }

@@
expression x,E;
position r.p1,r.p2;
statement S;
@@

*x =@p2 E
...
list_for_each_entry@p1(x,...) S
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
 drivers/mtd/ubi/cdev.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 4dfa6b9..3d2d1a6 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -798,18 +798,18 @@ static int rename_volumes(struct ubi_device *ubi,
 			goto out_free;
 		}
 
-		re = kzalloc(sizeof(struct ubi_rename_entry), GFP_KERNEL);
-		if (!re) {
+		re1 = kzalloc(sizeof(struct ubi_rename_entry), GFP_KERNEL);
+		if (!re1) {
 			err = -ENOMEM;
 			ubi_close_volume(desc);
 			goto out_free;
 		}
 
-		re->remove = 1;
-		re->desc = desc;
-		list_add(&re->list, &rename_list);
+		re1->remove = 1;
+		re1->desc = desc;
+		list_add(&re1->list, &rename_list);
 		dbg_msg("will remove volume %d, name \"%s\"",
-			re->desc->vol->vol_id, re->desc->vol->name);
+			re1->desc->vol->vol_id, re1->desc->vol->name);
 	}
 
 	mutex_lock(&ubi->device_mutex);
-- 
1.7.2.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] UBI: fix forward compatibility
  2010-08-29 12:12 UBI patches for 2.6.36 Artem Bityutskiy
  2010-08-29 12:13 ` [PATCH 1/2] UBI: eliminate update of list_for_each_entry loop cursor Artem Bityutskiy
@ 2010-08-29 12:14 ` Artem Bityutskiy
  1 sibling, 0 replies; 3+ messages in thread
From: Artem Bityutskiy @ 2010-08-29 12:14 UTC (permalink / raw)
  To: linux-mtd

From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>

Commit 0798cea8c2e1afee59686c51d27d0e96b05e42d1 "UBI: improve corrupted flash handling"
broke delet-compatible volumes handling - it introduced a limit of 8 eraseblocks which
may be corrupted. And delete-compatible eraseblocks are added to the "corrupted" list,
so if we'd have a large delete-compatible volume, UBI would refuse it.

The fix is to add delete-compatible volumes to the erase list instead. Indeed, they are
corrupted, we just have to erase them.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
 drivers/mtd/ubi/scan.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 372a15a..69b52e9 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -843,7 +843,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
 		case UBI_COMPAT_DELETE:
 			ubi_msg("\"delete\" compatible internal volume %d:%d"
 				" found, will remove it", vol_id, lnum);
-			err = add_to_list(si, pnum, ec, &si->corr);
+			err = add_to_list(si, pnum, ec, &si->erase);
 			if (err)
 				return err;
 			return 0;
-- 
1.7.2.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-08-29 12:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-29 12:12 UBI patches for 2.6.36 Artem Bityutskiy
2010-08-29 12:13 ` [PATCH 1/2] UBI: eliminate update of list_for_each_entry loop cursor Artem Bityutskiy
2010-08-29 12:14 ` [PATCH 2/2] UBI: fix forward compatibility Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).