]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ocfs2: fix possible memory leak in ocfs2_finish_quota_recovery
authorMurad Masimov <m.masimov@mt-integration.ru>
Wed, 2 Apr 2025 06:56:27 +0000 (09:56 +0300)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 12 May 2025 00:54:11 +0000 (17:54 -0700)
If ocfs2_finish_quota_recovery() exits due to an error before passing all
rc_list elements to ocfs2_recover_local_quota_file() then it can lead to a
memory leak as rc_list may still contain elements that have to be freed.

Release all memory allocated by ocfs2_add_recovery_chunk() using
ocfs2_free_quota_recovery() instead of kfree().

Found by Linux Verification Center (linuxtesting.org) with Syzkaller.

Link: https://lkml.kernel.org/r/20250402065628.706359-2-m.masimov@mt-integration.ru
Fixes: 2205363dce74 ("ocfs2: Implement quota recovery")
Signed-off-by: Murad Masimov <m.masimov@mt-integration.ru>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Jun Piao <piaojun@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/ocfs2/quota_local.c

index e272429da3db34ee770bb0772c1628e32ac7b52a..de7f12858729acfacb2cb13fbd2f9b5c7be58f29 100644 (file)
@@ -674,7 +674,7 @@ out_put:
                        break;
        }
 out:
-       kfree(rec);
+       ocfs2_free_quota_recovery(rec);
        return status;
 }