ceph: use struct_size() helper in __ceph_pool_perm_get()
authorThorsten Blum <thorsten.blum@toblux.com>
Thu, 12 Sep 2024 15:39:24 +0000 (17:39 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 3 Oct 2024 07:31:08 +0000 (09:31 +0200)
Use struct_size() to calculate the number of bytes to be allocated.

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/addr.c

index 53fef25..1d97a53 100644 (file)
@@ -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;