]> git.ipfire.org Git - thirdparty/linux.git/blobdiff - security/selinux/ss/policydb.c
Merge tag 'selinux-pr-20200601' of git://git.kernel.org/pub/scm/linux/kernel/git...
[thirdparty/linux.git] / security / selinux / ss / policydb.c
index a30cad18931b8ef94ba1b492a614d4bf6f8598ce..98f343005d6b5ae3d2a71c2b713570c5d769fdff 100644 (file)
@@ -1054,14 +1054,14 @@ static int str_read(char **strp, gfp_t flags, void *fp, u32 len)
        if (!str)
                return -ENOMEM;
 
-       /* it's expected the caller should free the str */
-       *strp = str;
-
        rc = next_entry(str, fp, len);
-       if (rc)
+       if (rc) {
+               kfree(str);
                return rc;
+       }
 
        str[len] = '\0';
+       *strp = str;
        return 0;
 }