Skip to contentSkip to conversation

gfs2: Fix refcount leak in gfs2_glock_poke

PATCH New Andreas Gruenbacher 2 participants 2 messages Aug 3, 2020

Subsystems (2)
lore
Share & tools
lore

Andreas Gruenbacher

author maintainer
#0 lore raw

PATCH 1/1 gfs2: Fix refcount leak in gfs2_glock_poke

In gfs2_glock_poke, make sure gfs2_holder_uninit is called on the local glock holder. Without that, we're leaking a glock and a pid reference.

Fixes 9e8990dea926 ("gfs2: Smarter iopen glock waiting")
Cc stable at vger.kernel.org # v5.8+
---
 fs/gfs2/glock.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/gfs2/glock.c +3 -1
index 57134d326cfa..f13b136654ca 100644
@@ -790,9 +790,11 @@ static void gfs2_glock_poke(struct gfs2_glock *gl)
 	struct gfs2_holder gh;
 	int error;
 
-	error = gfs2_glock_nq_init(gl, LM_ST_SHARED, flags, &gh);
+	gfs2_holder_init(gl, LM_ST_SHARED, flags, &gh);
+	error = gfs2_glock_nq(&gh);
 	if (!error)
 		gfs2_glock_dq(&gh);
+	gfs2_holder_uninit(&gh);
 }
 
 static bool gfs2_try_evict(struct gfs2_glock *gl)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/1 gfs2: Fix refcount leak in gfs2_glock_poke

----- Original Message -----

Quoted 28 lines

In gfs2_glock_poke, make sure gfs2_holder_uninit is called on the local glock holder. Without that, we're leaking a glock and a pid reference.

Fixes 9e8990dea926 ("gfs2: Smarter iopen glock waiting")
Cc stable at vger.kernel.org # v5.8+
---
 fs/gfs2/glock.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/gfs2/glock.c +3 -2
index 57134d326cfa..f13b136654ca 100644
@@ -790,9 +790,11 @@ static void gfs2_glock_poke(struct gfs2_glock *gl)
 	struct gfs2_holder gh;
 	int error;
 
-	error = gfs2_glock_nq_init(gl, LM_ST_SHARED, flags, &gh);
+	gfs2_holder_init(gl, LM_ST_SHARED, flags, &gh);
+	error = gfs2_glock_nq(&gh);
 	if (!error)
 		gfs2_glock_dq(&gh);
+	gfs2_holder_uninit(&gh);
 }
 
 static bool gfs2_try_evict(struct gfs2_glock *gl)
--
Quoted 1 line

2.26.2

Hi,

Looks okay.
I'd rather use nq_init and dq_uninit (and change similar code throughout to use it more consistently) but in the past you've expressed a concern that the compiler generates less efficient code.

Maybe it makes more sense to rework gfs2_glock_nq_init and dq_uninit so the compiler does a more reasonable job? Or I suppose we could delay that work for later.

Regards,

Bob Peterson