Commit ad94dc3a authored by Andrea Righi's avatar Andrea Righi Committed by Juergen Gross
Browse files

xen: use struct_size() helper in kzalloc()



struct privcmd_buf_vma_private has a zero-sized array at the end
(pages), use the new struct_size() helper to determine the proper
allocation size and avoid potential type mistakes.

Signed-off-by: default avatarAndrea Righi <andrea.righi@canonical.com>
Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
parent 0266def9
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -140,8 +140,7 @@ static int privcmd_buf_mmap(struct file *file, struct vm_area_struct *vma)
	if (!(vma->vm_flags & VM_SHARED))
		return -EINVAL;

	vma_priv = kzalloc(sizeof(*vma_priv) + count * sizeof(void *),
			   GFP_KERNEL);
	vma_priv = kzalloc(struct_size(vma_priv, pages, count), GFP_KERNEL);
	if (!vma_priv)
		return -ENOMEM;