Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ubifs: Fix memory leak bug in alloc_ubifs_info() error path

In ubifs_mount(), 'c' is allocated through kzalloc() in alloc_ubifs_info().
However, it is not deallocated in the following execution if
ubifs_fill_super() fails, leading to a memory leak bug. To fix this issue,
free 'c' before going to the 'out_deact' label.

Fixes: 1e51764a3c2a ("UBIFS: add new flash file system")
Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: Richard Weinberger <richard@nod.at>

authored by

Wenwen Wang and committed by
Richard Weinberger
9163e018 7992e004

+3 -1
+3 -1
fs/ubifs/super.c
··· 2256 2256 } 2257 2257 } else { 2258 2258 err = ubifs_fill_super(sb, data, flags & SB_SILENT ? 1 : 0); 2259 - if (err) 2259 + if (err) { 2260 + kfree(c); 2260 2261 goto out_deact; 2262 + } 2261 2263 /* We do not support atime */ 2262 2264 sb->s_flags |= SB_ACTIVE; 2263 2265 if (IS_ENABLED(CONFIG_UBIFS_ATIME_SUPPORT))