Commit 6b46d444 authored by Eric Biggers's avatar Eric Biggers Committed by Theodore Ts'o

ubifs: free the encrypted symlink target

ubifs_symlink() forgot to free the kmalloc()'ed buffer holding the
encrypted symlink target, creating a memory leak.  Fix it.

(UBIFS could actually encrypt directly into ui->data, removing the
temporary buffer, but that is left for the patch that switches to use
the symlink helper functions.)

Fixes: ca7f85be ("ubifs: Add support for encrypted symlinks")
Cc: <stable@vger.kernel.org> # v4.10+
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent f2329cb6
...@@ -1216,10 +1216,8 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry, ...@@ -1216,10 +1216,8 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry,
ostr.len = disk_link.len; ostr.len = disk_link.len;
err = fscrypt_fname_usr_to_disk(inode, &istr, &ostr); err = fscrypt_fname_usr_to_disk(inode, &istr, &ostr);
if (err) { if (err)
kfree(sd);
goto out_inode; goto out_inode;
}
sd->len = cpu_to_le16(ostr.len); sd->len = cpu_to_le16(ostr.len);
disk_link.name = (char *)sd; disk_link.name = (char *)sd;
...@@ -1251,11 +1249,10 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry, ...@@ -1251,11 +1249,10 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry,
goto out_cancel; goto out_cancel;
mutex_unlock(&dir_ui->ui_mutex); mutex_unlock(&dir_ui->ui_mutex);
ubifs_release_budget(c, &req);
insert_inode_hash(inode); insert_inode_hash(inode);
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
fscrypt_free_filename(&nm); err = 0;
return 0; goto out_fname;
out_cancel: out_cancel:
dir->i_size -= sz_change; dir->i_size -= sz_change;
...@@ -1268,6 +1265,7 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry, ...@@ -1268,6 +1265,7 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry,
fscrypt_free_filename(&nm); fscrypt_free_filename(&nm);
out_budg: out_budg:
ubifs_release_budget(c, &req); ubifs_release_budget(c, &req);
kfree(sd);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment