Skip to content

Commit 8267d8f

Browse files
Mikulas Patockasnitm
authored andcommitted
dm integrity: fix logic bug in integrity tag testing
If all the bytes are equal to DISCARD_FILLER, we want to accept the buffer. If any of the bytes are different, we must do thorough tag-by-tag checking. The condition was inverted. Fixes: 84597a4 ("dm integrity: add optional discard support") Signed-off-by: Mikulas Patocka <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent 120c925 commit 8267d8f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/md/dm-integrity.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,7 @@ static int dm_integrity_rw_tag(struct dm_integrity_c *ic, unsigned char *tag, se
13331333
if (likely(is_power_of_2(ic->tag_size))) {
13341334
if (unlikely(memcmp(dp, tag, to_copy)))
13351335
if (unlikely(!ic->discard) ||
1336-
unlikely(!memchr_inv(dp, DISCARD_FILLER, to_copy))) {
1336+
unlikely(memchr_inv(dp, DISCARD_FILLER, to_copy) != NULL)) {
13371337
goto thorough_test;
13381338
}
13391339
} else {

0 commit comments

Comments
 (0)