summaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-12-26 01:59:12 +0300
committerAl Viro <viro@zeniv.linux.org.uk>2016-01-04 18:28:19 +0300
commitcc4e719e83cd4149bc96b7e1d1a73fe61797df6e (patch)
tree6effdfd0106e269f2300b7b0bef8adcdd1ac7be0 /security
parent7812bf173a0a65a1227fe207ba8683c0afecb5e8 (diff)
downloadlinux-cc4e719e83cd4149bc96b7e1d1a73fe61797df6e.tar.xz
fix the leak in integrity_read_file()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'security')
-rw-r--r--security/integrity/iint.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/security/integrity/iint.c b/security/integrity/iint.c
index 3d2f5b45c8cb..c2e3ccd4b510 100644
--- a/security/integrity/iint.c
+++ b/security/integrity/iint.c
@@ -234,12 +234,13 @@ int __init integrity_read_file(const char *path, char **data)
}
rc = integrity_kernel_read(file, 0, buf, size);
- if (rc < 0)
- kfree(buf);
- else if (rc != size)
- rc = -EIO;
- else
+ if (rc == size) {
*data = buf;
+ } else {
+ kfree(buf);
+ if (rc >= 0)
+ rc = -EIO;
+ }
out:
fput(file);
return rc;