From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 3/5] xfs: fix double free in xlog_recover_commit_trans
Date: Fri, 26 Sep 2014 12:19:10 +1000 [thread overview]
Message-ID: <1411697952-24741-4-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1411697952-24741-1-git-send-email-david@fromorbit.com>
From: Dave Chinner <dchinner@redhat.com>
When an error occurs during buffer submission in
xlog_recover_commit_trans(), we free the trans structure twice. Fix
it by only freeing the structure in the caller regardless of the
success or failure of the function.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
fs/xfs/xfs_log_recover.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 685e98b..28eb078 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -3526,8 +3526,6 @@ out:
if (!list_empty(&done_list))
list_splice_init(&done_list, &trans->r_itemq);
- xlog_recover_free_trans(trans);
-
error2 = xfs_buf_delwri_submit(&buffer_list);
return error ? error : error2;
}
@@ -3552,6 +3550,10 @@ xlog_recovery_process_trans(
if (flags & XLOG_WAS_CONT_TRANS)
flags &= ~XLOG_CONTINUE_TRANS;
+ /*
+ * Callees must not free the trans structure. We'll decide if we need to
+ * free it or not based on the operation being done and it's result.
+ */
switch (flags) {
/* expected flag values */
case 0:
@@ -3563,6 +3565,8 @@ xlog_recovery_process_trans(
break;
case XLOG_COMMIT_TRANS:
error = xlog_recover_commit_trans(log, trans, pass);
+ /* success or fail, we are now done with this transaction. */
+ freeit = true;
break;
/* unexpected flag values */
--
2.0.0
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2014-09-26 2:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-26 2:19 [PATCH 0/5 v2] xfs: clean up xlog_recover_process_data Dave Chinner
2014-09-26 2:19 ` [PATCH 1/5] xfs: refactor xlog_recover_process_data() Dave Chinner
2014-09-26 11:42 ` Christoph Hellwig
2014-09-26 23:22 ` Dave Chinner
2014-09-26 2:19 ` [PATCH 2/5] xfs: recovery of XLOG_UNMOUNT_TRANS leaks memory Dave Chinner
2014-09-26 12:01 ` Christoph Hellwig
2014-09-26 23:27 ` Dave Chinner
2014-09-26 2:19 ` Dave Chinner [this message]
2014-09-26 2:19 ` [PATCH 4/5] xfs: reorganise transaction recovery item code Dave Chinner
2014-09-26 12:05 ` Christoph Hellwig
2014-09-26 2:19 ` [PATCH 5/5] xfs: refactor recovery transaction start handling Dave Chinner
2014-09-26 12:08 ` Christoph Hellwig
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=1411697952-24741-4-git-send-email-david@fromorbit.com \
--to=david@fromorbit.com \
--cc=xfs@oss.sgi.com \
/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