cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH] gfs2: fix possible reference leak in gfs2_check_blk_type
@ 2020-10-30 10:13 Zhang Qilong
  2020-11-04 16:20 ` Bob Peterson
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang Qilong @ 2020-10-30 10:13 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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 <zhangqilong3@huawei.com>
---
 fs/gfs2/rgrp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index ee491bb9c1cc..dd3e888994f7 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -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;
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Cluster-devel] [PATCH] gfs2: fix possible reference leak in gfs2_check_blk_type
  2020-10-30 10:13 [Cluster-devel] [PATCH] gfs2: fix possible reference leak in gfs2_check_blk_type Zhang Qilong
@ 2020-11-04 16:20 ` Bob Peterson
  0 siblings, 0 replies; 2+ messages in thread
From: Bob Peterson @ 2020-11-04 16:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

----- Original Message -----
> 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 <zhangqilong3@huawei.com>
> ---
>  fs/gfs2/rgrp.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
> index ee491bb9c1cc..dd3e888994f7 100644
> --- a/fs/gfs2/rgrp.c
> +++ b/fs/gfs2/rgrp.c
> @@ -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;
> --
> 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(-)

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 92d799a193b8..b26d6fcb6915 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-04 16:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-30 10:13 [Cluster-devel] [PATCH] gfs2: fix possible reference leak in gfs2_check_blk_type Zhang Qilong
2020-11-04 16:20 ` Bob Peterson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).