diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ubifs/recovery.c | 7 | ||||
-rw-r--r-- | fs/ubifs/replay.c | 7 | ||||
-rw-r--r-- | fs/ubifs/scan.c | 14 |
3 files changed, 17 insertions, 11 deletions
diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c index 805605250f12..093a1ecb700f 100644 --- a/fs/ubifs/recovery.c +++ b/fs/ubifs/recovery.c | |||
@@ -543,8 +543,8 @@ static int drop_incomplete_group(struct ubifs_scan_leb *sleb, int *offs) | |||
543 | * | 543 | * |
544 | * This function does a scan of a LEB, but caters for errors that might have | 544 | * This function does a scan of a LEB, but caters for errors that might have |
545 | * been caused by the unclean unmount from which we are attempting to recover. | 545 | * been caused by the unclean unmount from which we are attempting to recover. |
546 | * | 546 | * Returns %0 in case of success, %-EUCLEAN if an unrecoverable corruption is |
547 | * This function returns %0 on success and a negative error code on failure. | 547 | * found, and a negative error code in case of failure. |
548 | */ | 548 | */ |
549 | struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum, | 549 | struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum, |
550 | int offs, void *sbuf, int grouped) | 550 | int offs, void *sbuf, int grouped) |
@@ -643,7 +643,8 @@ struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum, | |||
643 | goto corrupted; | 643 | goto corrupted; |
644 | default: | 644 | default: |
645 | dbg_err("unknown"); | 645 | dbg_err("unknown"); |
646 | goto corrupted; | 646 | err = -EINVAL; |
647 | goto error; | ||
647 | } | 648 | } |
648 | } | 649 | } |
649 | 650 | ||
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c index 769be42f39d6..2970500f32df 100644 --- a/fs/ubifs/replay.c +++ b/fs/ubifs/replay.c | |||
@@ -837,9 +837,10 @@ static int replay_log_leb(struct ubifs_info *c, int lnum, int offs, void *sbuf) | |||
837 | 837 | ||
838 | dbg_mnt("replay log LEB %d:%d", lnum, offs); | 838 | dbg_mnt("replay log LEB %d:%d", lnum, offs); |
839 | sleb = ubifs_scan(c, lnum, offs, sbuf); | 839 | sleb = ubifs_scan(c, lnum, offs, sbuf); |
840 | if (IS_ERR(sleb)) { | 840 | if (IS_ERR(sleb) ) { |
841 | if (c->need_recovery) | 841 | if (PTR_ERR(sleb) != -EUCLEAN || !c->need_recovery) |
842 | sleb = ubifs_recover_log_leb(c, lnum, offs, sbuf); | 842 | return PTR_ERR(sleb); |
843 | sleb = ubifs_recover_log_leb(c, lnum, offs, sbuf); | ||
843 | if (IS_ERR(sleb)) | 844 | if (IS_ERR(sleb)) |
844 | return PTR_ERR(sleb); | 845 | return PTR_ERR(sleb); |
845 | } | 846 | } |
diff --git a/fs/ubifs/scan.c b/fs/ubifs/scan.c index 165c14ba1a46..892ebfee4fe5 100644 --- a/fs/ubifs/scan.c +++ b/fs/ubifs/scan.c | |||
@@ -256,7 +256,9 @@ void ubifs_scanned_corruption(const struct ubifs_info *c, int lnum, int offs, | |||
256 | * @sbuf: scan buffer (must be c->leb_size) | 256 | * @sbuf: scan buffer (must be c->leb_size) |
257 | * | 257 | * |
258 | * This function scans LEB number @lnum and returns complete information about | 258 | * This function scans LEB number @lnum and returns complete information about |
259 | * its contents. Returns an error code in case of failure. | 259 | * its contents. Returns the scaned information in case of success and, |
260 | * %-EUCLEAN if the LEB neads recovery, and other negative error codes in case | ||
261 | * of failure. | ||
260 | */ | 262 | */ |
261 | struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, | 263 | struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, |
262 | int offs, void *sbuf) | 264 | int offs, void *sbuf) |
@@ -279,7 +281,6 @@ struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, | |||
279 | cond_resched(); | 281 | cond_resched(); |
280 | 282 | ||
281 | ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 0); | 283 | ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 0); |
282 | |||
283 | if (ret > 0) { | 284 | if (ret > 0) { |
284 | /* Padding bytes or a valid padding node */ | 285 | /* Padding bytes or a valid padding node */ |
285 | offs += ret; | 286 | offs += ret; |
@@ -304,7 +305,8 @@ struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, | |||
304 | goto corrupted; | 305 | goto corrupted; |
305 | default: | 306 | default: |
306 | dbg_err("unknown"); | 307 | dbg_err("unknown"); |
307 | goto corrupted; | 308 | err = -EINVAL; |
309 | goto error; | ||
308 | } | 310 | } |
309 | 311 | ||
310 | err = ubifs_add_snod(c, sleb, buf, offs); | 312 | err = ubifs_add_snod(c, sleb, buf, offs); |
@@ -317,8 +319,10 @@ struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, | |||
317 | len -= node_len; | 319 | len -= node_len; |
318 | } | 320 | } |
319 | 321 | ||
320 | if (offs % c->min_io_size) | 322 | if (offs % c->min_io_size) { |
321 | goto corrupted; | 323 | ubifs_err("empty space starts at non-aligned offset %d", offs); |
324 | goto corrupted;; | ||
325 | } | ||
322 | 326 | ||
323 | ubifs_end_scan(c, sleb, lnum, offs); | 327 | ubifs_end_scan(c, sleb, lnum, offs); |
324 | 328 | ||