Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <thorsten.blum@toblux.com>
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>

authored by

Thorsten Blum and committed by
Ilya Dryomov
7264745d 9852d85e

+1 -1
+1 -1
fs/ceph/addr.c
··· 2145 2145 } 2146 2146 2147 2147 pool_ns_len = pool_ns ? pool_ns->len : 0; 2148 - perm = kmalloc(sizeof(*perm) + pool_ns_len + 1, GFP_NOFS); 2148 + perm = kmalloc(struct_size(perm, pool_ns, pool_ns_len + 1), GFP_NOFS); 2149 2149 if (!perm) { 2150 2150 err = -ENOMEM; 2151 2151 goto out_unlock;