ref: 358f3f8f49a50ea3f2032a31eb73f16411fad8a4
parent: 321eba33ebbadfe61ece480f877260788c6cf8b8
author: Kaho Ng <ngkaho1234@gmail.com>
date: Tue Jun 28 13:18:52 EDT 2016
ext4_journal: fix memory leakage when revoking a block repeatedly
--- a/src/ext4_journal.c
+++ b/src/ext4_journal.c
@@ -1656,8 +1656,16 @@
int jbd_trans_revoke_block(struct jbd_trans *trans,
ext4_fsblk_t lba)
{
- struct jbd_revoke_rec *rec =
- calloc(1, sizeof(struct jbd_revoke_rec));
+ struct jbd_revoke_rec tmp_rec = {
+ .lba = lba
+ }, *rec;
+ rec = RB_FIND(jbd_revoke_tree,
+ &trans->revoke_root,
+ &tmp_rec);
+ if (rec)
+ return EOK;
+
+ rec = calloc(1, sizeof(struct jbd_revoke_rec));
if (!rec)
return ENOMEM;