Skip to contentSkip to conversation

xfs: avoid double free on xlog_recover_commit_trans error

PATCH In review Eric Sandeen 2 participants 2 messages Aug 1, 2014 – Aug 2, 2014 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: avoid double free on xlog_recover_commit_trans error

xlog_recover_process_data() frees the transaction on any error out of the oh_flags switch statement, but in the XLOG_COMMIT_TRANS / xlog_recover_commit_trans() case, the transaction has already been freed in xlog_recover_commit_trans() before the error is returned.

Avoid this by only freeing the transaction in xlog_recover_commit_trans() if no error will be returned.

(Coverity spotted this)

---

fs/xfs/xfs_log_recover.c +4 -2
index 981af0f..e634ffd 100644
@@ -3514,9 +3514,11 @@ 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);
+	/* caller will free trans on error */
+	if (!error && !error2)
+		xlog_recover_free_trans(trans);
+
 	return error ? error : error2;
 }
 

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw
Quoted 10 lines · Eric Sandeen

xlog_recover_process_data() frees the transaction on any error out of the oh_flags switch statement, but in the XLOG_COMMIT_TRANS / xlog_recover_commit_trans() case, the transaction has already been freed in xlog_recover_commit_trans() before the error is returned.

Avoid this by only freeing the transaction in xlog_recover_commit_trans() if no error will be returned.

(Coverity spotted this)

Ok, I see that Mark already sent this (thanks Mark, sorry for not seeing / remembering) and he was scolded for not thinking hard enough about the problem. I guess I'm not thinking hard enough either...

Sorry 'bout that.

-Eric

Quoted 22 lines

---

fs/xfs/xfs_log_recover.c +4 -2
index 981af0f..e634ffd 100644
@@ -3514,9 +3514,11 @@ 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);
+	/* caller will free trans on error */
+	if (!error && !error2)
+		xlog_recover_free_trans(trans);
+
 	return error ? error : error2;
 }
 
Quoted 5 lines

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs