提交 588558eb 编写于 作者: C Colin Ian King 提交者: John Johansen

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: 1180b4c7 ("apparmor: fix dangling symlinks to policy rawdata after replacement")
Signed-off-by: NColin Ian King <colin.king@canonical.com>
Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
上级 1180b4c7
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册