diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-06-18 05:06:30 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-07-18 09:55:55 -0400 |
commit | 94784d916458d51043ba76849b9beaf330baef2f (patch) | |
tree | a7b71f0aa61ce5524dc602716c6ae722ff78d461 /drivers/mtd | |
parent | 7753f1692f53d82b4cc08084462b0fd2803c1f04 (diff) |
UBI: bugfix in error path
When volume creation fails, we have to set ubi->volumes[vol_id]
back to NULL.
This patch also tweaks some debugging stuff.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/ubi/debug.c | 6 | ||||
-rw-r--r-- | drivers/mtd/ubi/debug.h | 2 | ||||
-rw-r--r-- | drivers/mtd/ubi/vmt.c | 6 | ||||
-rw-r--r-- | drivers/mtd/ubi/vtbl.c | 3 |
4 files changed, 7 insertions, 10 deletions
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index 9a996c5280f9..310341e5cd43 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c | |||
@@ -91,7 +91,7 @@ void ubi_dbg_dump_vol_info(const struct ubi_volume *vol) | |||
91 | 91 | ||
92 | if (vol->name_len <= UBI_VOL_NAME_MAX && | 92 | if (vol->name_len <= UBI_VOL_NAME_MAX && |
93 | strnlen(vol->name, vol->name_len + 1) == vol->name_len) { | 93 | strnlen(vol->name, vol->name_len + 1) == vol->name_len) { |
94 | dbg_msg("name %s", vol->name); | 94 | dbg_msg("name %s", vol->name); |
95 | } else { | 95 | } else { |
96 | dbg_msg("the 1st 5 characters of the name: %c%c%c%c%c", | 96 | dbg_msg("the 1st 5 characters of the name: %c%c%c%c%c", |
97 | vol->name[0], vol->name[1], vol->name[2], | 97 | vol->name[0], vol->name[1], vol->name[2], |
@@ -117,13 +117,13 @@ void ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) | |||
117 | dbg_msg("name_len %d", name_len); | 117 | dbg_msg("name_len %d", name_len); |
118 | 118 | ||
119 | if (r->name[0] == '\0') { | 119 | if (r->name[0] == '\0') { |
120 | dbg_msg("name NULL"); | 120 | dbg_msg("name NULL"); |
121 | return; | 121 | return; |
122 | } | 122 | } |
123 | 123 | ||
124 | if (name_len <= UBI_VOL_NAME_MAX && | 124 | if (name_len <= UBI_VOL_NAME_MAX && |
125 | strnlen(&r->name[0], name_len + 1) == name_len) { | 125 | strnlen(&r->name[0], name_len + 1) == name_len) { |
126 | dbg_msg("name %s", &r->name[0]); | 126 | dbg_msg("name %s", &r->name[0]); |
127 | } else { | 127 | } else { |
128 | dbg_msg("1st 5 characters of the name: %c%c%c%c%c", | 128 | dbg_msg("1st 5 characters of the name: %c%c%c%c%c", |
129 | r->name[0], r->name[1], r->name[2], r->name[3], | 129 | r->name[0], r->name[1], r->name[2], r->name[3], |
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index f816ad9a36c0..ff8f39548cd8 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h | |||
@@ -52,7 +52,6 @@ struct ubi_scan_volume; | |||
52 | struct ubi_scan_leb; | 52 | struct ubi_scan_leb; |
53 | struct ubi_mkvol_req; | 53 | struct ubi_mkvol_req; |
54 | 54 | ||
55 | void ubi_dbg_print(int type, const char *func, const char *fmt, ...); | ||
56 | void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr); | 55 | void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr); |
57 | void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr); | 56 | void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr); |
58 | void ubi_dbg_dump_vol_info(const struct ubi_volume *vol); | 57 | void ubi_dbg_dump_vol_info(const struct ubi_volume *vol); |
@@ -66,7 +65,6 @@ void ubi_dbg_hexdump(const void *buf, int size); | |||
66 | 65 | ||
67 | #define dbg_msg(fmt, ...) ({}) | 66 | #define dbg_msg(fmt, ...) ({}) |
68 | #define ubi_dbg_dump_stack() ({}) | 67 | #define ubi_dbg_dump_stack() ({}) |
69 | #define ubi_dbg_print(func, fmt, ...) ({}) | ||
70 | #define ubi_dbg_dump_ec_hdr(ec_hdr) ({}) | 68 | #define ubi_dbg_dump_ec_hdr(ec_hdr) ({}) |
71 | #define ubi_dbg_dump_vid_hdr(vid_hdr) ({}) | 69 | #define ubi_dbg_dump_vid_hdr(vid_hdr) ({}) |
72 | #define ubi_dbg_dump_vol_info(vol) ({}) | 70 | #define ubi_dbg_dump_vol_info(vol) ({}) |
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index 6e135996e42d..a0c6e1e6d465 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c | |||
@@ -228,7 +228,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) | |||
228 | for (i = 0; i < ubi->vtbl_slots; i++) | 228 | for (i = 0; i < ubi->vtbl_slots; i++) |
229 | if (ubi->volumes[i] && | 229 | if (ubi->volumes[i] && |
230 | ubi->volumes[i]->name_len == req->name_len && | 230 | ubi->volumes[i]->name_len == req->name_len && |
231 | strcmp(ubi->volumes[i]->name, req->name) == 0) { | 231 | !strcmp(ubi->volumes[i]->name, req->name)) { |
232 | dbg_err("volume \"%s\" exists (ID %d)", req->name, i); | 232 | dbg_err("volume \"%s\" exists (ID %d)", req->name, i); |
233 | goto out_unlock; | 233 | goto out_unlock; |
234 | } | 234 | } |
@@ -351,6 +351,7 @@ out_acc: | |||
351 | spin_lock(&ubi->volumes_lock); | 351 | spin_lock(&ubi->volumes_lock); |
352 | ubi->rsvd_pebs -= vol->reserved_pebs; | 352 | ubi->rsvd_pebs -= vol->reserved_pebs; |
353 | ubi->avail_pebs += vol->reserved_pebs; | 353 | ubi->avail_pebs += vol->reserved_pebs; |
354 | ubi->volumes[vol_id] = NULL; | ||
354 | out_unlock: | 355 | out_unlock: |
355 | spin_unlock(&ubi->volumes_lock); | 356 | spin_unlock(&ubi->volumes_lock); |
356 | kfree(vol); | 357 | kfree(vol); |
@@ -367,6 +368,7 @@ out_sysfs: | |||
367 | spin_lock(&ubi->volumes_lock); | 368 | spin_lock(&ubi->volumes_lock); |
368 | ubi->rsvd_pebs -= vol->reserved_pebs; | 369 | ubi->rsvd_pebs -= vol->reserved_pebs; |
369 | ubi->avail_pebs += vol->reserved_pebs; | 370 | ubi->avail_pebs += vol->reserved_pebs; |
371 | ubi->volumes[vol_id] = NULL; | ||
370 | spin_unlock(&ubi->volumes_lock); | 372 | spin_unlock(&ubi->volumes_lock); |
371 | volume_sysfs_close(vol); | 373 | volume_sysfs_close(vol); |
372 | return err; | 374 | return err; |
@@ -784,7 +786,7 @@ static void paranoid_check_volume(const struct ubi_device *ubi, int vol_id) | |||
784 | return; | 786 | return; |
785 | 787 | ||
786 | fail: | 788 | fail: |
787 | ubi_err("paranoid check failed"); | 789 | ubi_err("paranoid check failed for volume %d", vol_id); |
788 | ubi_dbg_dump_vol_info(vol); | 790 | ubi_dbg_dump_vol_info(vol); |
789 | ubi_dbg_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id); | 791 | ubi_dbg_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id); |
790 | BUG(); | 792 | BUG(); |
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 800ce940a820..1f48c76cf6fe 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c | |||
@@ -96,9 +96,6 @@ int ubi_change_vtbl_record(struct ubi_device *ubi, int idx, | |||
96 | vtbl_rec->crc = cpu_to_be32(crc); | 96 | vtbl_rec->crc = cpu_to_be32(crc); |
97 | } | 97 | } |
98 | 98 | ||
99 | dbg_msg("change record %d", idx); | ||
100 | ubi_dbg_dump_vtbl_record(vtbl_rec, idx); | ||
101 | |||
102 | mutex_lock(&ubi->vtbl_mutex); | 99 | mutex_lock(&ubi->vtbl_mutex); |
103 | memcpy(&ubi->vtbl[idx], vtbl_rec, sizeof(struct ubi_vtbl_record)); | 100 | memcpy(&ubi->vtbl[idx], vtbl_rec, sizeof(struct ubi_vtbl_record)); |
104 | for (i = 0; i < UBI_LAYOUT_VOLUME_EBS; i++) { | 101 | for (i = 0; i < UBI_LAYOUT_VOLUME_EBS; i++) { |