linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Czerner <lczerner@redhat.com>
To: tytso@mit.edu
Cc: linux-ext4@vger.kernel.org, Lukas Czerner <lczerner@redhat.com>
Subject: [PATCH 2/2] jbd2: Fix memory leak in jbd2_journal_stop()
Date: Wed,  6 May 2015 10:05:14 +0200	[thread overview]
Message-ID: <1430899514-19128-2-git-send-email-lczerner@redhat.com> (raw)
In-Reply-To: <1430899514-19128-1-git-send-email-lczerner@redhat.com>

Currently in the case that we've got to the jbd2_journal_stop() with
already sopped handle we might leak the memory previously allocated
for the reserved handle because we only free the handle structure
leaving handle->h_rsv_handle intact.

Fix it by freeing the handle->h_rsv_handle structure in case we're
dealing with already stopped handle in jbd2_journal_stop().

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 fs/jbd2/transaction.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 34bd0c5..807c378 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -1535,8 +1535,11 @@ int jbd2_journal_stop(handle_t *handle)
 			jbd_debug(4, "h_ref %d -> %d\n", handle->h_ref + 1,
 							 handle->h_ref);
 			return err;
-		} else
+		} else {
+			if (handle->h_rsv_handle)
+				jbd2_free_handle(handle->h_rsv_handle);
 			goto free_and_exit;
+		}
 	}
 	journal = transaction->t_journal;
 
-- 
1.8.3.1


  reply	other threads:[~2015-05-06  8:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-06  8:05 [PATCH 1/2] ext4: fix NULL pointer dereference when journal restart fails Lukas Czerner
2015-05-06  8:05 ` Lukas Czerner [this message]
2015-05-12 12:24 ` Jan Kara
2015-05-12 12:59   ` Lukáš Czerner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1430899514-19128-2-git-send-email-lczerner@redhat.com \
    --to=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).