Commit 6b74fdcc authored by Kent Overstreet's avatar Kent Overstreet
Browse files

bcachefs: bch2_checksum() returns 0 for unknown checksum type



This fixes missing guards on trying to calculate a checksum with an
invalid/unknown checksum type; moving the guards up to e.g. btree_io.c
might be "more correct", but doesn't buy us anything - an unknown
checksum type will always be flagged as at least a checksum error so we
aren't losing any safety doing it this way and it makes it less likely
to accidentally pop an assert we don't want.

Reported-by: default avatar <syzbot+e951ad5349f3a34a715a@syzkaller.appspotmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent c06a8b75
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -233,7 +233,7 @@ struct bch_csum bch2_checksum(struct bch_fs *c, unsigned type,
		return ret;
	}
	default:
		BUG();
		return (struct bch_csum) {};
	}
}

@@ -307,7 +307,7 @@ static struct bch_csum __bch2_checksum_bio(struct bch_fs *c, unsigned type,
		return ret;
	}
	default:
		BUG();
		return (struct bch_csum) {};
	}
}