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>
This commit is contained in:
parent
7753f1692f
commit
94784d9164
@ -91,7 +91,7 @@ void ubi_dbg_dump_vol_info(const struct ubi_volume *vol)
|
|||||||
|
|
||||||
if (vol->name_len <= UBI_VOL_NAME_MAX &&
|
if (vol->name_len <= UBI_VOL_NAME_MAX &&
|
||||||
strnlen(vol->name, vol->name_len + 1) == vol->name_len) {
|
strnlen(vol->name, vol->name_len + 1) == vol->name_len) {
|
||||||
dbg_msg("name %s", vol->name);
|
dbg_msg("name %s", vol->name);
|
||||||
} else {
|
} else {
|
||||||
dbg_msg("the 1st 5 characters of the name: %c%c%c%c%c",
|
dbg_msg("the 1st 5 characters of the name: %c%c%c%c%c",
|
||||||
vol->name[0], vol->name[1], vol->name[2],
|
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)
|
|||||||
dbg_msg("name_len %d", name_len);
|
dbg_msg("name_len %d", name_len);
|
||||||
|
|
||||||
if (r->name[0] == '\0') {
|
if (r->name[0] == '\0') {
|
||||||
dbg_msg("name NULL");
|
dbg_msg("name NULL");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name_len <= UBI_VOL_NAME_MAX &&
|
if (name_len <= UBI_VOL_NAME_MAX &&
|
||||||
strnlen(&r->name[0], name_len + 1) == name_len) {
|
strnlen(&r->name[0], name_len + 1) == name_len) {
|
||||||
dbg_msg("name %s", &r->name[0]);
|
dbg_msg("name %s", &r->name[0]);
|
||||||
} else {
|
} else {
|
||||||
dbg_msg("1st 5 characters of the name: %c%c%c%c%c",
|
dbg_msg("1st 5 characters of the name: %c%c%c%c%c",
|
||||||
r->name[0], r->name[1], r->name[2], r->name[3],
|
r->name[0], r->name[1], r->name[2], r->name[3],
|
||||||
|
@ -52,7 +52,6 @@ struct ubi_scan_volume;
|
|||||||
struct ubi_scan_leb;
|
struct ubi_scan_leb;
|
||||||
struct ubi_mkvol_req;
|
struct ubi_mkvol_req;
|
||||||
|
|
||||||
void ubi_dbg_print(int type, const char *func, const char *fmt, ...);
|
|
||||||
void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr);
|
void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr);
|
||||||
void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr);
|
void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr);
|
||||||
void ubi_dbg_dump_vol_info(const struct ubi_volume *vol);
|
void ubi_dbg_dump_vol_info(const struct ubi_volume *vol);
|
||||||
@ -66,7 +65,6 @@ void ubi_dbg_hexdump(const void *buf, int size);
|
|||||||
|
|
||||||
#define dbg_msg(fmt, ...) ({})
|
#define dbg_msg(fmt, ...) ({})
|
||||||
#define ubi_dbg_dump_stack() ({})
|
#define ubi_dbg_dump_stack() ({})
|
||||||
#define ubi_dbg_print(func, fmt, ...) ({})
|
|
||||||
#define ubi_dbg_dump_ec_hdr(ec_hdr) ({})
|
#define ubi_dbg_dump_ec_hdr(ec_hdr) ({})
|
||||||
#define ubi_dbg_dump_vid_hdr(vid_hdr) ({})
|
#define ubi_dbg_dump_vid_hdr(vid_hdr) ({})
|
||||||
#define ubi_dbg_dump_vol_info(vol) ({})
|
#define ubi_dbg_dump_vol_info(vol) ({})
|
||||||
|
@ -228,7 +228,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
|
|||||||
for (i = 0; i < ubi->vtbl_slots; i++)
|
for (i = 0; i < ubi->vtbl_slots; i++)
|
||||||
if (ubi->volumes[i] &&
|
if (ubi->volumes[i] &&
|
||||||
ubi->volumes[i]->name_len == req->name_len &&
|
ubi->volumes[i]->name_len == req->name_len &&
|
||||||
strcmp(ubi->volumes[i]->name, req->name) == 0) {
|
!strcmp(ubi->volumes[i]->name, req->name)) {
|
||||||
dbg_err("volume \"%s\" exists (ID %d)", req->name, i);
|
dbg_err("volume \"%s\" exists (ID %d)", req->name, i);
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
@ -351,6 +351,7 @@ out_acc:
|
|||||||
spin_lock(&ubi->volumes_lock);
|
spin_lock(&ubi->volumes_lock);
|
||||||
ubi->rsvd_pebs -= vol->reserved_pebs;
|
ubi->rsvd_pebs -= vol->reserved_pebs;
|
||||||
ubi->avail_pebs += vol->reserved_pebs;
|
ubi->avail_pebs += vol->reserved_pebs;
|
||||||
|
ubi->volumes[vol_id] = NULL;
|
||||||
out_unlock:
|
out_unlock:
|
||||||
spin_unlock(&ubi->volumes_lock);
|
spin_unlock(&ubi->volumes_lock);
|
||||||
kfree(vol);
|
kfree(vol);
|
||||||
@ -367,6 +368,7 @@ out_sysfs:
|
|||||||
spin_lock(&ubi->volumes_lock);
|
spin_lock(&ubi->volumes_lock);
|
||||||
ubi->rsvd_pebs -= vol->reserved_pebs;
|
ubi->rsvd_pebs -= vol->reserved_pebs;
|
||||||
ubi->avail_pebs += vol->reserved_pebs;
|
ubi->avail_pebs += vol->reserved_pebs;
|
||||||
|
ubi->volumes[vol_id] = NULL;
|
||||||
spin_unlock(&ubi->volumes_lock);
|
spin_unlock(&ubi->volumes_lock);
|
||||||
volume_sysfs_close(vol);
|
volume_sysfs_close(vol);
|
||||||
return err;
|
return err;
|
||||||
@ -784,7 +786,7 @@ static void paranoid_check_volume(const struct ubi_device *ubi, int vol_id)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
ubi_err("paranoid check failed");
|
ubi_err("paranoid check failed for volume %d", vol_id);
|
||||||
ubi_dbg_dump_vol_info(vol);
|
ubi_dbg_dump_vol_info(vol);
|
||||||
ubi_dbg_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id);
|
ubi_dbg_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id);
|
||||||
BUG();
|
BUG();
|
||||||
|
@ -96,9 +96,6 @@ int ubi_change_vtbl_record(struct ubi_device *ubi, int idx,
|
|||||||
vtbl_rec->crc = cpu_to_be32(crc);
|
vtbl_rec->crc = cpu_to_be32(crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
dbg_msg("change record %d", idx);
|
|
||||||
ubi_dbg_dump_vtbl_record(vtbl_rec, idx);
|
|
||||||
|
|
||||||
mutex_lock(&ubi->vtbl_mutex);
|
mutex_lock(&ubi->vtbl_mutex);
|
||||||
memcpy(&ubi->vtbl[idx], vtbl_rec, sizeof(struct ubi_vtbl_record));
|
memcpy(&ubi->vtbl[idx], vtbl_rec, sizeof(struct ubi_vtbl_record));
|
||||||
for (i = 0; i < UBI_LAYOUT_VOLUME_EBS; i++) {
|
for (i = 0; i < UBI_LAYOUT_VOLUME_EBS; i++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user