diff options
author | Andrea Righi <andrea.righi@canonical.com> | 2019-04-03 01:26:36 -0400 |
---|---|---|
committer | Juergen Gross <jgross@suse.com> | 2019-04-05 02:42:41 -0400 |
commit | ad94dc3a7eb5fa6ff469dbcf401c44b14ad50595 (patch) | |
tree | 04c7feffd21b0a2ecfdcb23b0293a8d44019c8ea | |
parent | 0266def913771e718fd0c998eecb072e0685e2c9 (diff) |
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>
-rw-r--r-- | drivers/xen/privcmd-buf.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/xen/privcmd-buf.c b/drivers/xen/privcmd-buf.c index de01a6d0059d..a1c61e351d3f 100644 --- a/drivers/xen/privcmd-buf.c +++ b/drivers/xen/privcmd-buf.c | |||
@@ -140,8 +140,7 @@ static int privcmd_buf_mmap(struct file *file, struct vm_area_struct *vma) | |||
140 | if (!(vma->vm_flags & VM_SHARED)) | 140 | if (!(vma->vm_flags & VM_SHARED)) |
141 | return -EINVAL; | 141 | return -EINVAL; |
142 | 142 | ||
143 | vma_priv = kzalloc(sizeof(*vma_priv) + count * sizeof(void *), | 143 | vma_priv = kzalloc(struct_size(vma_priv, pages, count), GFP_KERNEL); |
144 | GFP_KERNEL); | ||
145 | if (!vma_priv) | 144 | if (!vma_priv) |
146 | return -ENOMEM; | 145 | return -ENOMEM; |
147 | 146 | ||