Merge tag 'Smack-for-6.0' of https://github.com/cschaufler/smack-next
[linux-2.6-microblaze.git] / security / smack / smack_access.c
index d2186e2..585e5e3 100644 (file)
@@ -465,12 +465,9 @@ char *smk_parse_smack(const char *string, int len)
        if (i == 0 || i >= SMK_LONGLABEL)
                return ERR_PTR(-EINVAL);
 
-       smack = kzalloc(i + 1, GFP_NOFS);
-       if (smack == NULL)
+       smack = kstrndup(string, i, GFP_NOFS);
+       if (!smack)
                return ERR_PTR(-ENOMEM);
-
-       strncpy(smack, string, i);
-
        return smack;
 }