The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] dm snap: clear pointers in alloc_area() error paths
@ 2026-11-27  9:58 Shuai Liu
  2026-11-27 12:04 ` Deepak Pandey
  0 siblings, 1 reply; 2+ messages in thread
From: Shuai Liu @ 2026-11-27  9:58 UTC (permalink / raw)
  To: dm-devel
  Cc: agk, snitzer, mpatocka, bmarzins, linux-kernel,
	syzbot+1eda626824b6334f5ad3, Shuai Liu

alloc_area() vfrees ps->zero_area and ps->area on allocation failure
but leaves the dangling pointers.  When the snapshot constructor then
calls free_area() as part of teardown, it vfrees the same buffers
again, triggering a WARNING in vfree().

Set those pointers to NULL after vfree().  vfree(NULL) is a no-op,
so free_area() is safe to call multiple times.

Reported-by: syzbot+1eda626824b6334f5ad3@syzkaller.appspotmail.com
Fixes: 7c9e6c17325f ("dm exception store: refactor zero_area")
Signed-off-by: Shuai Liu <847807867@qq.com>
---
 drivers/md/dm-snap-persistent.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c
index b587ee7330562..9f5ade4f51cec 100644
--- a/drivers/md/dm-snap-persistent.c
+++ b/drivers/md/dm-snap-persistent.c
@@ -194,9 +194,11 @@ static int alloc_area(struct pstore *ps)
 
 err_header_area:
 	vfree(ps->zero_area);
+	ps->zero_area = NULL;
 
 err_zero_area:
 	vfree(ps->area);
+	ps->area = NULL;
 
 err_area:
 	return r;
-- 
2.43.0


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

end of thread, other threads:[~2026-11-27 12:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27  9:58 [PATCH] dm snap: clear pointers in alloc_area() error paths Shuai Liu
2026-11-27 12:04 ` Deepak Pandey

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