From: Thorsten Blum Date: Thu, 12 Sep 2024 15:39:24 +0000 (+0200) Subject: ceph: use struct_size() helper in __ceph_pool_perm_get() X-Git-Tag: v6.12-rc2~27^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7264745d55422dbe53b5e75ddec622ab5d1290cb;p=thirdparty%2Flinux.git ceph: use struct_size() helper in __ceph_pool_perm_get() Use struct_size() to calculate the number of bytes to be allocated. Signed-off-by: Thorsten Blum Reviewed-by: Ilya Dryomov Signed-off-by: Ilya Dryomov --- diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 53fef258c2bc6..1d97a53d1b297 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -2145,7 +2145,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, } pool_ns_len = pool_ns ? pool_ns->len : 0; - perm = kmalloc(sizeof(*perm) + pool_ns_len + 1, GFP_NOFS); + perm = kmalloc(struct_size(perm, pool_ns, pool_ns_len + 1), GFP_NOFS); if (!perm) { err = -ENOMEM; goto out_unlock;