mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dm thin metadata: fix superblock refcount leak on snapshot shadow failure
@ 2026-07-11 10:05 Genjian
  2026-07-13  2:40 ` Ming Hung Tsai
  0 siblings, 1 reply; 3+ messages in thread
From: Genjian @ 2026-07-11 10:05 UTC (permalink / raw)
  To: agk, snitzer, mpatocka, bmarzins, ejt
  Cc: dm-devel, linux-kernel, Genjian Zhang

From: Genjian Zhang <zhanggenjian@kylinos.cn>

__reserve_metadata_snap() increments THIN_SUPERBLOCK_LOCATION in the
metadata space map before shadowing it. When dm_tm_shadow_block()
fails, a reference is leaked in the metadata space map.

Fix by adding the missing dm_sm_dec_block().

Fixes: cc8394d86f04 ("dm thin: provide userspace access to pool metadata")
Signed-off-by: Genjian Zhang <zhanggenjian@kylinos.cn>
---
 drivers/md/dm-thin-metadata.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
index b6a2d2081a24..b194fb57d158 100644
--- a/drivers/md/dm-thin-metadata.c
+++ b/drivers/md/dm-thin-metadata.c
@@ -1353,8 +1353,10 @@ static int __reserve_metadata_snap(struct dm_pool_metadata *pmd)
 	dm_sm_inc_block(pmd->metadata_sm, THIN_SUPERBLOCK_LOCATION);
 	r = dm_tm_shadow_block(pmd->tm, THIN_SUPERBLOCK_LOCATION,
 			       &sb_validator, &copy, &inc);
-	if (r)
+	if (r) {
+		dm_sm_dec_block(pmd->metadata_sm, THIN_SUPERBLOCK_LOCATION);
 		return r;
+	}
 
 	BUG_ON(!inc);
 
-- 
2.43.0


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

end of thread, other threads:[~2026-07-13 13:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-11 10:05 [PATCH] dm thin metadata: fix superblock refcount leak on snapshot shadow failure Genjian
2026-07-13  2:40 ` Ming Hung Tsai
2026-07-13 13:49   ` genjian zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®