summaryrefslogtreecommitdiffstats
path: root/kernel/audit_tree.c
diff options
context:
space:
mode:
authorXiu Jianfeng <xiujianfeng@huawei.com>2021-12-14 12:48:54 +0100
committerPaul Moore <paul@paul-moore.com>2021-12-14 23:39:42 +0100
commitbc6e60a4fc1daef2d95367fea8ee74fc5b62b7d6 (patch)
tree0cfc61274ea2b8a6b19a8862b59fb1b67935d32b /kernel/audit_tree.c
parentLinux 5.16-rc1 (diff)
downloadlinux-bc6e60a4fc1daef2d95367fea8ee74fc5b62b7d6.tar.xz
linux-bc6e60a4fc1daef2d95367fea8ee74fc5b62b7d6.zip
audit: use struct_size() helper in kmalloc()
Make use of struct_size() helper instead of an open-coded calucation. Link: https://github.com/KSPP/linux/issues/160 Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'kernel/audit_tree.c')
-rw-r--r--kernel/audit_tree.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index 72324afcffef..e7315d487163 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -94,7 +94,7 @@ static struct audit_tree *alloc_tree(const char *s)
{
struct audit_tree *tree;
- tree = kmalloc(sizeof(struct audit_tree) + strlen(s) + 1, GFP_KERNEL);
+ tree = kmalloc(struct_size(tree, pathname, strlen(s) + 1), GFP_KERNEL);
if (tree) {
refcount_set(&tree->count, 1);
tree->goner = 0;