mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-30 22:26:55 +00:00
dm-integrity: fix a memory leak when rechecking the data
[ Upstream commit55e565c42d
] Memory for the "checksums" pointer will leak if the data is rechecked after checksum failure (because the associated kfree won't happen due to 'goto skip_io'). Fix this by freeing the checksums memory before recheck, and just use the "checksum_onstack" memory for storing checksum during recheck. Fixes:c88f5e553f
("dm-integrity: recheck the integrity tag after a failure") Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
b29a5055ee
commit
20e21c3c01
1 changed files with 4 additions and 4 deletions
|
@ -1856,12 +1856,12 @@ static void integrity_metadata(struct work_struct *w)
|
|||
r = dm_integrity_rw_tag(ic, checksums, &dio->metadata_block, &dio->metadata_offset,
|
||||
checksums_ptr - checksums, dio->op == REQ_OP_READ ? TAG_CMP : TAG_WRITE);
|
||||
if (unlikely(r)) {
|
||||
if (r > 0) {
|
||||
integrity_recheck(dio, checksums);
|
||||
goto skip_io;
|
||||
}
|
||||
if (likely(checksums != checksums_onstack))
|
||||
kfree(checksums);
|
||||
if (r > 0) {
|
||||
integrity_recheck(dio, checksums_onstack);
|
||||
goto skip_io;
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue