apparmor: Fix error cod in __aa_fs_profile_mkdir()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 23 May 2017 14:33:46 +0000 (17:33 +0300)
committerJohn Johansen <john.johansen@canonical.com>
Thu, 8 Jun 2017 18:21:05 +0000 (11:21 -0700)
We can either return PTR_ERR(NULL) or a PTR_ERR(a valid pointer) here.
Returning NULL is probably not good, but since this happens at boot
then we are probably already toasted if we were to hit this bug in real
life.  In other words, it seems like a very low severity bug to me.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/apparmorfs.c

index 41e427a4f05108c3fbd5d95fca18f16ce64d484a..26ad1a37063275479a0794cf770327c799180c87 100644 (file)
@@ -727,8 +727,10 @@ int __aa_fs_profile_mkdir(struct aa_profile *profile, struct dentry *parent)
                id_len = snprintf(NULL, 0, ".%ld", profile->ns->uniq_id);
 
                profile->dirname = kmalloc(len + id_len + 1, GFP_KERNEL);
-               if (!profile->dirname)
-                       goto fail;
+               if (!profile->dirname) {
+                       error = -ENOMEM;
+                       goto fail2;
+               }
 
                mangle_name(profile->base.name, profile->dirname);
                sprintf(profile->dirname + len, ".%ld", profile->ns->uniq_id++);