gfs2: fix possible reference leak in gfs2_check_blk_type
PATCH 1/1 gfs2: fix possible reference leak in gfs2_check_blk_type
In the fail path of gfs2_check_blk_type, forgetting to call gfs2_glock_dq_uninit will result in rgd_gh reference leak.
Signed-off-by Zhang Qilong <[email protected]>
--- fs/gfs2/rgrp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/gfs2/rgrp.c +3 -1
@@ -2526,8 +2526,10 @@ int gfs2_check_blk_type(struct gfs2_sbd *sdp, u64 no_addr, unsigned int type) rbm.rgd = rgd; error =gfs2_rbm_from_block (&rbm, no_addr); -if (WARN_ON_ONCE (error)) +if (WARN_ON_ONCE (error)) { +gfs2_glock_dq_uninit (&rgd_gh); goto fail; + }if (gfs2_testbit (&rbm, false) != type) error = -ESTALE ;
Signature · 1 line
2.17.1
PATCH 1/1 gfs2: fix possible reference leak in gfs2_check_blk_type
----- Original Message -----
Quoted 24 lines
In the fail path of
gfs2_check_blk_type, forgetting to callgfs2_glock_dq_uninitwill result inrgd_ghreference leak.Signed-off-by Zhang Qilong <[email protected]>--- fs/gfs2/rgrp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)fs/gfs2/rgrp.c +3
-1@@ -2526,8 +2526,10 @@ int gfs2_check_blk_type(struct gfs2_sbd *sdp, u64 no_addr, unsigned int type) rbm.rgd = rgd; error =gfs2_rbm_from_block (&rbm, no_addr); -if (WARN_ON_ONCE (error)) +if (WARN_ON_ONCE (error)) { +gfs2_glock_dq_uninit (&rgd_gh); goto fail; + }if (gfs2_testbit (&rbm, false) != type)
Quoted 3 lines
error =
-ESTALE;
--
2.17.1
Hi,
Thanks. This is clearly a bug. Can we do something like this instead? Andreas, which do you prefer?
fs/gfs2/rgrp.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
fs/gfs2/rgrp.c +4 -6
@@ -2529,12 +2529,10 @@ int gfs2_check_blk_type(struct gfs2_sbd *sdp, u64 no_addr, unsigned int type) rbm.rgd = rgd; error =gfs2_rbm_from_block (&rbm, no_addr); -if (WARN_ON_ONCE (error)) - goto fail; - -if (gfs2_testbit (&rbm, false) != type) - error = -ESTALE ; - +if (!WARN_ON_ONCE (error)) { +if (gfs2_testbit (&rbm, false) != type) + error = -ESTALE ; + }gfs2_glock_dq_uninit (&rgd_gh); fail:return error;
Regards,
Bob Peterson