Skip to content

Commit d4a3806

Browse files
Mikulas PatockaMike Snitzer
authored andcommitted
dm integrity: fix double free on memory allocation failure
If the statement "recalc_tags = kvmalloc(recalc_tags_size, GFP_NOIO);" fails, we call "vfree(recalc_buffer)" and we jump to the label "oom". If the condition "recalc_sectors >= 1U << ic->sb->log2_sectors_per_block" is false, we jump to the label "free_ret" and call "vfree(recalc_buffer)" again, on an already released memory block. Fix the bug by setting "recalc_buffer = NULL" after freeing it. Fixes: da8b4fc ("dm integrity: only allocate recalculate buffer when needed") Signed-off-by: Mikulas Patocka <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent fdf0eaf commit d4a3806

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/md/dm-integrity.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,6 +2676,7 @@ static void integrity_recalc(struct work_struct *w)
26762676
recalc_tags = kvmalloc(recalc_tags_size, GFP_NOIO);
26772677
if (!recalc_tags) {
26782678
vfree(recalc_buffer);
2679+
recalc_buffer = NULL;
26792680
goto oom;
26802681
}
26812682

0 commit comments

Comments
 (0)