diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-12-25 23:59:12 +0100 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-01-04 16:28:19 +0100 |
commit | cc4e719e83cd4149bc96b7e1d1a73fe61797df6e (patch) | |
tree | 6effdfd0106e269f2300b7b0bef8adcdd1ac7be0 /security/integrity/iint.c | |
parent | ppc: get rid of the remnants of __get_user64() (diff) | |
download | linux-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/integrity/iint.c')
-rw-r--r-- | security/integrity/iint.c | 11 |
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; |