Skip to content

Commit 9786cab

Browse files
committed
Merge tag 'selinux-pr-20200416' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux
Pull SELinux fix from Paul Moore: "One small SELinux fix to ensure we cleanup properly on an error condition" * tag 'selinux-pr-20200416' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux: selinux: free str on error in str_read()
2 parents 3fa84bf + af15f14 commit 9786cab

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

security/selinux/ss/policydb.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,14 +1035,14 @@ static int str_read(char **strp, gfp_t flags, void *fp, u32 len)
10351035
if (!str)
10361036
return -ENOMEM;
10371037

1038-
/* it's expected the caller should free the str */
1039-
*strp = str;
1040-
10411038
rc = next_entry(str, fp, len);
1042-
if (rc)
1039+
if (rc) {
1040+
kfree(str);
10431041
return rc;
1042+
}
10441043

10451044
str[len] = '\0';
1045+
*strp = str;
10461046
return 0;
10471047
}
10481048

0 commit comments

Comments
 (0)