Thread (20 messages) 20 messages, 3 authors, 2021-05-29
STALE1830d REVIEWED: 1 (0M)
Revisions (2)
  1. v1 current
  2. v2 [diff vs current]

[PATCH 03/12] zap_sector: fix memory leak

From: Wu Guanghao <hidden>
Date: 2021-05-24 11:21:02
Subsystem: the rest · Maintainer: Linus Torvalds

In zap_sector(), need free buf before return,
otherwise it will cause memory leak.

Signed-off-by: Wu Guanghao <redacted>
Signed-off-by: Zhiqiang Liu <redacted>
Reviewed-by: Wu Bo <redacted>
---
 misc/mke2fs.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index afbcf486..94f81da9 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -586,6 +586,7 @@ static void zap_sector(ext2_filsys fs, int sect, int nsect)
 			magic = (unsigned int *) (buf + BSD_LABEL_OFFSET);
 			if ((*magic == BSD_DISKMAGIC) ||
 				(*magic == BSD_MAGICDISK))
+				free(buf);
 				return;
 		}
 	}
-- 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help