summaryrefslogtreecommitdiffstats
path: root/fs/jbd2/transaction.c
diff options
context:
space:
mode:
authorChengguang Xu <cgxu519@gmail.com>2019-05-10 21:15:47 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-05-22 07:37:44 +0200
commit5b8567682489dbbb0742c9fc3f6711bb6a01f540 (patch)
treea6001b5c476c3b30f36ca53e987e8af76d874673 /fs/jbd2/transaction.c
parent95482af27161083976c7f5bdf347992deb3767ce (diff)
downloadlinux-stable-5b8567682489dbbb0742c9fc3f6711bb6a01f540.tar.gz
linux-stable-5b8567682489dbbb0742c9fc3f6711bb6a01f540.tar.bz2
linux-stable-5b8567682489dbbb0742c9fc3f6711bb6a01f540.zip
jbd2: fix potential double free
commit 0d52154bb0a700abb459a2cbce0a30fc2549b67e upstream. When failing from creating cache jbd2_inode_cache, we will destroy the previously created cache jbd2_handle_cache twice. This patch fixes this by moving each cache initialization/destruction to its own separate, individual function. Signed-off-by: Chengguang Xu <cgxu519@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/jbd2/transaction.c')
-rw-r--r--fs/jbd2/transaction.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 914e725c82c4..e20a6703531f 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -42,9 +42,11 @@ int __init jbd2_journal_init_transaction_cache(void)
0,
SLAB_HWCACHE_ALIGN|SLAB_TEMPORARY,
NULL);
- if (transaction_cache)
- return 0;
- return -ENOMEM;
+ if (!transaction_cache) {
+ pr_emerg("JBD2: failed to create transaction cache\n");
+ return -ENOMEM;
+ }
+ return 0;
}
void jbd2_journal_destroy_transaction_cache(void)