Message ID | 20210630082724.50838-4-wuguanghao3@huawei.com |
---|---|
State | Accepted |
Headers | show |
Series | [v2,01/12] profile_create_node: set magic before strdup(name) to avoid memory leak | expand |
On Wed, Jun 30, 2021 at 04:27:15PM +0800, wuguanghao wrote: > In zap_sector(), need free buf before return, > otherwise it will cause memory leak. > > Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com> > Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> > Reviewed-by: Wu Bo <wubo40@huawei.com> Thanks, applied. - Ted
diff --git a/misc/mke2fs.c b/misc/mke2fs.c index afbcf486..68e36ecc 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -585,8 +585,10 @@ static void zap_sector(ext2_filsys fs, int sect, int nsect) else { magic = (unsigned int *) (buf + BSD_LABEL_OFFSET); if ((*magic == BSD_DISKMAGIC) || - (*magic == BSD_MAGICDISK)) + (*magic == BSD_MAGICDISK)) { + free(buf); return; + } } }