Revert "ubifs: Fix memory leak bug in alloc_ubifs_info() error path"
diff mbox series

Message ID 20191030145201.3597-1-s.hauer@pengutronix.de
State Superseded
Headers show
Series
  • Revert "ubifs: Fix memory leak bug in alloc_ubifs_info() error path"
Related show

Commit Message

Sascha Hauer Oct. 30, 2019, 2:52 p.m. UTC
This reverts commit 9163e0184bd7d5f779934d34581843f699ad2ffd.

There actually is no memory leak. After an sget() the ubifs info
structure will be freed in the kill_sb hook. Doing it again here
leads to a double free.
As this is non obvious leave a comment where c is freed.

Fixes: 9163e0184bd7 ("ubifs: Fix memory leak bug in alloc_ubifs_info() error path")
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/ubifs/super.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 7d4547e5202d..ce1515d693a0 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -2267,10 +2267,9 @@  static struct dentry *ubifs_mount(struct file_system_type *fs_type, int flags,
 		}
 	} else {
 		err = ubifs_fill_super(sb, data, flags & SB_SILENT ? 1 : 0);
-		if (err) {
-			kfree(c);
+		if (err)
+			/* c will be freed in ubifs_fs_type.kill_sb */
 			goto out_deact;
-		}
 		/* We do not support atime */
 		sb->s_flags |= SB_ACTIVE;
 		if (IS_ENABLED(CONFIG_UBIFS_ATIME_SUPPORT))