Skip to content

Commit

Permalink
dm integrity: call kmem_cache_destroy() in dm_integrity_init() error …
Browse files Browse the repository at this point in the history
…path

commit 6b79a42 upstream.

Otherwise the journal_io_cache will leak if dm_register_target() fails.

Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Mike Snitzer authored and gregkh committed May 11, 2023
1 parent f3063e8 commit e09a592
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/md/dm-integrity.c
Original file line number Diff line number Diff line change
Expand Up @@ -4703,11 +4703,13 @@ static int __init dm_integrity_init(void)
}

r = dm_register_target(&integrity_target);

if (r < 0)
if (r < 0) {
DMERR("register failed %d", r);
kmem_cache_destroy(journal_io_cache);
return r;
}

return r;
return 0;
}

static void __exit dm_integrity_exit(void)
Expand Down

0 comments on commit e09a592

Please sign in to comment.