summaryrefslogtreecommitdiffstats
path: root/security/selinux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2020-04-16 19:45:47 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2020-04-16 19:45:47 +0200
commit9786cab674574239b04df638f825ee0e7d76a48c (patch)
treedb7eab6edc35fde4ac7e0dbc3d7a0fe076449a32 /security/selinux
parentMerge tag 'ceph-for-5.7-rc2' of git://github.com/ceph/ceph-client (diff)
parentselinux: free str on error in str_read() (diff)
downloadlinux-9786cab674574239b04df638f825ee0e7d76a48c.tar.xz
linux-9786cab674574239b04df638f825ee0e7d76a48c.zip
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()
Diffstat (limited to 'security/selinux')
-rw-r--r--security/selinux/ss/policydb.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index 70ecdc78efbd..c21b922e5ebe 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -1035,14 +1035,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;
}