diff mbox

[08/14] UBUNTU: SAUCE: apparmor: fix reference count leak when securityfs_setup_d_inode() fails

Message ID 20170201091310.22695-9-john.johansen@canonical.com
State New
Headers show

Commit Message

John Johansen Feb. 1, 2017, 9:13 a.m. UTC
BugLink: http://bugs.launchpad.net/bugs/1660845
Signed-off-by: John Johansen <john.johansen@canonical.com>
---
 security/apparmor/apparmorfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 019dba8..a12e8ab 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -1052,12 +1052,12 @@  static int ns_mkdir_op(struct inode *dir, struct dentry *dentry, umode_t mode)
 	error = securityfs_pin_fs();
 	inode_lock_nested(dir, I_MUTEX_PARENT);
 	if (error)
-		return error;
+		goto out;
 
 	error = __securityfs_setup_d_inode(dir, dentry, mode | S_IFDIR,  NULL,
 					   NULL, NULL);
 	if (error)
-		return error;
+		goto out;
 
 	ns = aa_create_ns(parent, ACCESS_ONCE(dentry->d_name.name), dentry);
 	if (IS_ERR(ns)) {
@@ -1066,6 +1066,7 @@  static int ns_mkdir_op(struct inode *dir, struct dentry *dentry, umode_t mode)
 	}
 
 	aa_put_ns(ns);		/* list ref remains */
+out:
 	aa_put_ns(parent);
 
 	return error;