ocfs2: fix possible double free in ocfs2_reflink_xattr_rec
PATCH 1/1 ocfs2: fix possible double free in ocfs2_reflink_xattr_rec
In ocfs2_reflink_xattr_rec(), meta_ac and data_ac are allocated by calling ocfs2_lock_reflink_xattr_rec_allocators().
Once an error occurs when allocating *data_ac, it frees *meta_ac which is allocated before. Here it mistakenly sets meta_ac to NULL but *meta_ac. Then ocfs2_reflink_xattr_rec() will try to free meta_ac again which is already invalid.
--- fs/ocfs2/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/xattr.c +1 -1
@@ -6799,7 +6799,7 @@ out:if (ret) {if (*meta_ac) {ocfs2_free_alloc_context (*meta_ac); - meta_ac =NULL ; + *meta_ac =NULL ; } }
Signature · 1 line
1.7.9.7
PATCH 1/1 ocfs2: fix possible double free in ocfs2_reflink_xattr_rec
Quoted 8 lines · Joseph Qi
In
ocfs2_reflink_xattr_rec(),meta_acanddata_acare allocated by callingocfs2_lock_reflink_xattr_rec_allocators().
Once an error occurs when allocating*data_ac, it frees*meta_acwhich is allocated before. Here it mistakenly setsmeta_acto NULL but*meta_ac. Thenocfs2_reflink_xattr_rec()will try to freemeta_acagain which is already invalid.Signed-off-by Joseph Qi <[email protected]>
Looks good to me, thanks.
Quoted 17 lines
--- fs/ocfs2/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/ocfs2/xattr.c +1
-1@@ -6799,7 +6799,7 @@ out:if (ret) {if (*meta_ac) {ocfs2_free_alloc_context (*meta_ac); - meta_ac =NULL ; + *meta_ac =NULL ; } }