ubifs: Fix memory leak in error path in ubifs_mknod

Submitted by Richard Weinberger on Feb. 10, 2017, 4:46 p.m.

Details

Message ID 20170210164601.29218-1-richard@nod.at
State New
Delegated to: Richard Weinberger
Headers show

Commit Message

Richard Weinberger Feb. 10, 2017, 4:46 p.m.
When fscrypt_setup_filename() fails we have to free dev.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 fs/ubifs/dir.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 528369f3e472..e164782f8bc8 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1068,8 +1068,10 @@  static int ubifs_mknod(struct inode *dir, struct dentry *dentry,
 	}
 
 	err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
-	if (err)
+	if (err) {
+		kfree(dev);
 		goto out_budg;
+	}
 
 	sz_change = CALC_DENT_SIZE(fname_len(&nm));