From: Al Viro Date: Fri, 25 Dec 2015 22:59:12 +0000 (-0500) Subject: fix the leak in integrity_read_file() X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=cc4e719e83cd4149bc96b7e1d1a73fe61797df6e;p=linux-beck.git fix the leak in integrity_read_file() Signed-off-by: Al Viro --- 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;