Skip to content

Commit ad94dc3

Browse files
Andrea Righijgross1
authored andcommitted
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: Andrea Righi <andrea.righi@canonical.com> Reviewed-by: Juergen Gross <jgross@suse.com> Signed-off-by: Juergen Gross <jgross@suse.com>
1 parent 0266def commit ad94dc3

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/xen/privcmd-buf.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ static int privcmd_buf_mmap(struct file *file, struct vm_area_struct *vma)
140140
if (!(vma->vm_flags & VM_SHARED))
141141
return -EINVAL;
142142

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

0 commit comments

Comments
 (0)