Skip to content

Commit 588558e

Browse files
Colin Ian Kingjrjohansen
authored andcommitted
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: 1180b4c ("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>
1 parent 1180b4c commit 588558e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

security/apparmor/apparmorfs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1497,8 +1497,10 @@ static char *gen_symlink_name(int depth, const char *dirname, const char *fname)
14971497
}
14981498

14991499
error = snprintf(s, size, "raw_data/%s/%s", dirname, fname);
1500-
if (error >= size || error < 0)
1500+
if (error >= size || error < 0) {
1501+
kfree(buffer);
15011502
return ERR_PTR(-ENAMETOOLONG);
1503+
}
15021504

15031505
return buffer;
15041506
}

0 commit comments

Comments
 (0)