mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-25 13:14:07 +08:00
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: 1180b4c757
("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>
This commit is contained in:
parent
1180b4c757
commit
588558eb6d
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user