Skip to contentSkip to conversation

gfs2: use kmem_cache_free() instead of kfree()

PATCH In review Wei Yongjun 2 participants 2 messages Apr 9, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gfs2: use kmem_cache_free() instead of kfree()

memory allocated by kmem_cache_alloc() should be freed using kmem_cache_free(), not kfree().

Fixes 7d6eec37a105 ("gfs2: Allocate bufdata object before taking log lock")
---
 fs/gfs2/trans.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/gfs2/trans.c +3 -3
index c50de22d7cbf..1b47d08ac4fb 100644
@@ -206,7 +206,7 @@ void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh)
 	}
 	gfs2_log_lock(sdp);
 	if (bh->b_private) {
-		kfree(bd);
+		kmem_cache_free(gfs2_bufdata_cachep, bd);
 		bd = bh->b_private;
 	} else {
 		bh->b_private = bd;
@@ -246,12 +246,12 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh)
 	}
 	gfs2_log_lock(sdp);
 	if (bh->b_private) {
-		kfree(bd);
+		kmem_cache_free(gfs2_bufdata_cachep, bd);
 		bd = bh->b_private;
 	} else {
 		lock_page(bh->b_page);
 		if (bh->b_private) {
-			kfree(bd);
+			kmem_cache_free(gfs2_bufdata_cachep, bd);
 			bd = bh->b_private;
 		} else {
 			bh->b_private = bd;
#1 lore raw

Hi,

Am Fr., 9. Apr. 2021 um 10:20 Uhr schrieb Wei Yongjun <[email protected]>:

Quoted 2 lines

memory allocated by kmem_cache_alloc() should be freed using kmem_cache_free(), not kfree().

thanks for the patch, that's true. This patch has turned out to have other problems as well, so we've pulled it and Bob is currently investigating.

Andreas