From cc4e719e83cd4149bc96b7e1d1a73fe61797df6e Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 25 Dec 2015 17:59:12 -0500 Subject: fix the leak in integrity_read_file() Signed-off-by: Al Viro --- security/integrity/iint.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'security') 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; -- cgit v1.2.3-59-g8ed1b