gfs2: Free rd_bits later in gfs2_clear_rgrpd to fix use-after-free
authorBob Peterson <rpeterso@redhat.com>
Tue, 27 Oct 2020 15:10:01 +0000 (10:10 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Nov 2020 17:24:59 +0000 (18:24 +0100)
commit89d2da2495f0fb61a1678e644095cd7857a5a00f
treeada277d867ab34c8d440b46db55f18ada691fb81
parent71e893cf15d2466696360d39a50d7a722bdae648
gfs2: Free rd_bits later in gfs2_clear_rgrpd to fix use-after-free

[ Upstream commit d0f17d3883f1e3f085d38572c2ea8edbd5150172 ]

Function gfs2_clear_rgrpd calls kfree(rgd->rd_bits) before calling
return_all_reservations, but return_all_reservations still dereferences
rgd->rd_bits in __rs_deltree.  Fix that by moving the call to kfree below the
call to return_all_reservations.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/gfs2/rgrp.c