summaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2018-03-27 15:35:58 +0200
committerJohn Johansen <john.johansen@canonical.com>2018-03-31 06:14:04 +0200
commit588558eb6d0e0b6edfa65a67e906c2ffeba63ff1 (patch)
treece7b8c97b9af43136d47cadf3ee9350436c9b8e3 /security
parentapparmor: fix dangling symlinks to policy rawdata after replacement (diff)
downloadlinux-588558eb6d0e0b6edfa65a67e906c2ffeba63ff1.tar.xz
linux-588558eb6d0e0b6edfa65a67e906c2ffeba63ff1.zip
apparmor: fix memory leak on buffer on error exit path
Currently on the error exit path the allocated buffer is not free'd causing a memory leak. Fix this by kfree'ing it. Detected by CoverityScan, CID#1466876 ("Resource leaks") Fixes: 1180b4c757aa ("apparmor: fix dangling symlinks to policy rawdata after replacement") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: John Johansen <john.johansen@canonical.com>
Diffstat (limited to 'security')
-rw-r--r--security/apparmor/apparmorfs.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 62301ddbbe5e..f4308683c0af 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -1497,8 +1497,10 @@ static char *gen_symlink_name(int depth, const char *dirname, const char *fname)
}
error = snprintf(s, size, "raw_data/%s/%s", dirname, fname);
- if (error >= size || error < 0)
+ if (error >= size || error < 0) {
+ kfree(buffer);
return ERR_PTR(-ENAMETOOLONG);
+ }
return buffer;
}