summaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-12-25 23:59:12 +0100
committerAl Viro <viro@zeniv.linux.org.uk>2016-01-04 16:28:19 +0100
commitcc4e719e83cd4149bc96b7e1d1a73fe61797df6e (patch)
tree6effdfd0106e269f2300b7b0bef8adcdd1ac7be0 /security
parentppc: get rid of the remnants of __get_user64() (diff)
downloadlinux-cc4e719e83cd4149bc96b7e1d1a73fe61797df6e.tar.xz
linux-cc4e719e83cd4149bc96b7e1d1a73fe61797df6e.zip
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;